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'
import { pseudoRandomBytes } from 'crypto'
import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs'
import * as mkdirp from 'mkdirp'
-import { join } from 'path'
+import { isAbsolute, join } from 'path'
import * as pem from 'pem'
import * as rimraf from 'rimraf'
import { URL } from 'url'
@@ -70,6 +70,12 @@ function pageToStartAndCount (page: number, itemsPerPage: number) {
return { start, count: itemsPerPage }
}
+function buildPath (path: string) {
+ if (isAbsolute(path)) return path
+
+ return join(root(), path)
+}
+
function promisify0 (func: (cb: (err: any, result: A) => void) => void): () => Promise {
return function promisified (): Promise {
return new Promise((resolve: (arg: A) => void, reject: (err: any) => void) => {
@@ -136,6 +142,7 @@ export {
pageToStartAndCount,
sanitizeUrl,
sanitizeHost,
+ buildPath,
promisify0,
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'
import { FollowState } from '../../shared/models/actors'
import { VideoPrivacy } from '../../shared/models/videos'
// Do not use barrels, remain constants as independent as possible
-import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
+import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
// ---------------------------------------------------------------------------
@@ -93,13 +93,13 @@ const CONFIG = {
PASSWORD: config.get('database.password')
},
STORAGE: {
- AVATARS_DIR: join(root(), config.get('storage.avatars')),
- LOG_DIR: join(root(), config.get('storage.logs')),
- VIDEOS_DIR: join(root(), config.get('storage.videos')),
- THUMBNAILS_DIR: join(root(), config.get('storage.thumbnails')),
- PREVIEWS_DIR: join(root(), config.get('storage.previews')),
- TORRENTS_DIR: join(root(), config.get('storage.torrents')),
- CACHE_DIR: join(root(), config.get('storage.cache'))
+ AVATARS_DIR: buildPath(config.get('storage.avatars')),
+ LOG_DIR: buildPath(config.get('storage.logs')),
+ VIDEOS_DIR: buildPath(config.get('storage.videos')),
+ THUMBNAILS_DIR: buildPath(config.get('storage.thumbnails')),
+ PREVIEWS_DIR: buildPath(config.get('storage.previews')),
+ TORRENTS_DIR: buildPath(config.get('storage.torrents')),
+ CACHE_DIR: buildPath(config.get('storage.cache'))
},
WEBSERVER: {
SCHEME: config.get('webserver.https') === true ? 'https' : 'http',