From f4800714f906eabd1762d42179e538f5c4a11d68 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Mar 2019 10:53:53 +0100 Subject: [PATCH] Cleanup tmp directory at startup --- server/initializers/installer.ts | 6 ++++-- server/tests/api/users/users-multiple-servers.ts | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 349d7afb7..cd2c942fd 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts @@ -24,7 +24,7 @@ async function installApplication () { }), // Directories - removeCacheDirectories() + removeCacheAndTmpDirectories() .then(() => createDirectoriesIfNotExist()) ]) } catch (err) { @@ -41,7 +41,7 @@ export { // --------------------------------------------------------------------------- -function removeCacheDirectories () { +function removeCacheAndTmpDirectories () { const cacheDirectories = Object.keys(CACHE) .map(k => CACHE[k].DIRECTORY) @@ -53,6 +53,8 @@ function removeCacheDirectories () { tasks.push(remove(dir)) } + tasks.push(remove(CONFIG.STORAGE.TMP_DIR)) + return Promise.all(tasks) } diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 006d6cdf0..c46c2b7d7 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -4,6 +4,7 @@ import * as chai from 'chai' import 'mocha' import { Account } from '../../../../shared/models/actors' import { + checkTmpIsEmpty, checkVideoFilesWereRemoved, createUser, doubleFollow, @@ -216,6 +217,12 @@ describe('Test users with multiple servers', function () { } }) + it('Should have an empty tmp directory', async function () { + for (const server of servers) { + await checkTmpIsEmpty(server) + } + }) + after(async function () { killallServers(servers) }) -- 2.25.1