diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-16 08:46:44 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-16 08:46:44 +0100 |
commit | 0b4204f9832d2616e87959b6b547958b5c8677fb (patch) | |
tree | b1d3019235deaa0ab6c989734fdba537418dca6a /server | |
parent | 2d13b29965482cebfd2070d5acf010af75416925 (diff) | |
download | PeerTube-0b4204f9832d2616e87959b6b547958b5c8677fb.tar.gz PeerTube-0b4204f9832d2616e87959b6b547958b5c8677fb.tar.zst PeerTube-0b4204f9832d2616e87959b6b547958b5c8677fb.zip |
Fix config storage paths
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/core-utils.ts | 9 | ||||
-rw-r--r-- | server/initializers/constants.ts | 16 |
2 files changed, 16 insertions, 9 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 4981bb4ec..77547c528 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts | |||
@@ -8,7 +8,7 @@ import * as createTorrent from 'create-torrent' | |||
8 | import { pseudoRandomBytes } from 'crypto' | 8 | import { pseudoRandomBytes } from 'crypto' |
9 | import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs' | 9 | import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs' |
10 | import * as mkdirp from 'mkdirp' | 10 | import * as mkdirp from 'mkdirp' |
11 | import { join } from 'path' | 11 | import { isAbsolute, join } from 'path' |
12 | import * as pem from 'pem' | 12 | import * as pem from 'pem' |
13 | import * as rimraf from 'rimraf' | 13 | import * as rimraf from 'rimraf' |
14 | import { URL } from 'url' | 14 | import { URL } from 'url' |
@@ -70,6 +70,12 @@ function pageToStartAndCount (page: number, itemsPerPage: number) { | |||
70 | return { start, count: itemsPerPage } | 70 | return { start, count: itemsPerPage } |
71 | } | 71 | } |
72 | 72 | ||
73 | function buildPath (path: string) { | ||
74 | if (isAbsolute(path)) return path | ||
75 | |||
76 | return join(root(), path) | ||
77 | } | ||
78 | |||
73 | function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> { | 79 | function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> { |
74 | return function promisified (): Promise<A> { | 80 | return function promisified (): Promise<A> { |
75 | return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => { | 81 | return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => { |
@@ -136,6 +142,7 @@ export { | |||
136 | pageToStartAndCount, | 142 | pageToStartAndCount, |
137 | sanitizeUrl, | 143 | sanitizeUrl, |
138 | sanitizeHost, | 144 | sanitizeHost, |
145 | buildPath, | ||
139 | 146 | ||
140 | promisify0, | 147 | promisify0, |
141 | promisify1, | 148 | promisify1, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 2c64efe1f..745e50168 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -5,7 +5,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub' | |||
5 | import { FollowState } from '../../shared/models/actors' | 5 | import { FollowState } from '../../shared/models/actors' |
6 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoPrivacy } from '../../shared/models/videos' |
7 | // Do not use barrels, remain constants as independent as possible | 7 | // Do not use barrels, remain constants as independent as possible |
8 | import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 8 | import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
11 | 11 | ||
@@ -93,13 +93,13 @@ const CONFIG = { | |||
93 | PASSWORD: config.get<string>('database.password') | 93 | PASSWORD: config.get<string>('database.password') |
94 | }, | 94 | }, |
95 | STORAGE: { | 95 | STORAGE: { |
96 | AVATARS_DIR: join(root(), config.get<string>('storage.avatars')), | 96 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), |
97 | LOG_DIR: join(root(), config.get<string>('storage.logs')), | 97 | LOG_DIR: buildPath(config.get<string>('storage.logs')), |
98 | VIDEOS_DIR: join(root(), config.get<string>('storage.videos')), | 98 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), |
99 | THUMBNAILS_DIR: join(root(), config.get<string>('storage.thumbnails')), | 99 | THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), |
100 | PREVIEWS_DIR: join(root(), config.get<string>('storage.previews')), | 100 | PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), |
101 | TORRENTS_DIR: join(root(), config.get<string>('storage.torrents')), | 101 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), |
102 | CACHE_DIR: join(root(), config.get<string>('storage.cache')) | 102 | CACHE_DIR: buildPath(config.get<string>('storage.cache')) |
103 | }, | 103 | }, |
104 | WEBSERVER: { | 104 | WEBSERVER: { |
105 | SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http', | 105 | SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http', |