1
0
Fork 0

Fix config storage paths

This commit is contained in:
Chocobozzz 2018-01-16 08:46:44 +01:00
parent 2d13b29965
commit 0b4204f983
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 16 additions and 9 deletions

View file

@ -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<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) => {
@ -136,6 +142,7 @@ export {
pageToStartAndCount,
sanitizeUrl,
sanitizeHost,
buildPath,
promisify0,
promisify1,

View file

@ -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<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',