X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Futils.ts;h=0545e89961bf6cd2b3780fbef50077d1d2f8ecd3;hb=d223dca0cd50010d1c4455e5eec1736b1c591aed;hp=11c11829285954db39224a0e53c7945d87119acd;hpb=d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 11c118292..0545e8996 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -1,13 +1,10 @@ +import { remove } from 'fs-extra' +import { Instance as ParseTorrent } from 'parse-torrent' +import { join } from 'path' import { ResultList } from '../../shared' -import { ApplicationModel } from '../models/application/application' +import { CONFIG } from '../initializers/config' import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' import { logger } from './logger' -import { join } from 'path' -import { Instance as ParseTorrent } from 'parse-torrent' -import { remove } from 'fs-extra' -import * as memoizee from 'memoizee' -import { CONFIG } from '../initializers/config' -import { isVideoFileExtnameValid } from './custom-validators/videos' function deleteFileAsync (path: string) { remove(path) @@ -33,26 +30,11 @@ function getFormattedObjects> (objects: } as ResultList } -const getServerActor = memoizee(async function () { - const application = await ApplicationModel.load() - if (!application) throw Error('Could not load Application from database.') - - const actor = application.Account.Actor - actor.Account = application.Account - - return actor -}, { promise: true }) - -function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) { +function generateVideoImportTmpPath (target: string | ParseTorrent, extension = '.mp4') { const id = typeof target === 'string' ? target : target.infoHash - let extension = '.mp4' - if (extensionArg && isVideoFileExtnameValid(extensionArg)) { - extension = extensionArg - } - const hash = sha256(id) return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`) } @@ -105,7 +87,6 @@ export { generateRandomString, getFormattedObjects, getSecureTorrentName, - getServerActor, getServerCommit, generateVideoImportTmpPath, getUUIDFromFilename