From 0b4204f9832d2616e87959b6b547958b5c8677fb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Jan 2018 08:46:44 +0100 Subject: Fix config storage paths --- server/helpers/core-utils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server/helpers') 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, -- cgit v1.2.3