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'
return { start, count: itemsPerPage }
}
+function buildPath (path: string) {
+ if (isAbsolute(path)) return path
+
+ return join(root(), path)
+}
+
function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> {
return function promisified (): Promise<A> {
return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => {
pageToStartAndCount,
sanitizeUrl,
sanitizeHost,
+ buildPath,
promisify0,
promisify1,
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'
// ---------------------------------------------------------------------------
PASSWORD: config.get<string>('database.password')
},
STORAGE: {
- AVATARS_DIR: join(root(), config.get<string>('storage.avatars')),
- LOG_DIR: join(root(), config.get<string>('storage.logs')),
- VIDEOS_DIR: join(root(), config.get<string>('storage.videos')),
- THUMBNAILS_DIR: join(root(), config.get<string>('storage.thumbnails')),
- PREVIEWS_DIR: join(root(), config.get<string>('storage.previews')),
- TORRENTS_DIR: join(root(), config.get<string>('storage.torrents')),
- CACHE_DIR: join(root(), config.get<string>('storage.cache'))
+ AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
+ LOG_DIR: buildPath(config.get<string>('storage.logs')),
+ VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
+ THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
+ PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
+ TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')),
+ CACHE_DIR: buildPath(config.get<string>('storage.cache'))
},
WEBSERVER: {
SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',