From ae3b487c4299d32624b4f52a5ef55227b5644b50 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Dec 2024 07:11:30 +0100 Subject: [PATCH] Fix user export expiration --- packages/tests/src/api/users/user-export.ts | 14 +++++++++----- server/core/models/user/user-export.ts | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/tests/src/api/users/user-export.ts b/packages/tests/src/api/users/user-export.ts index 8e06313b9..d35177fb5 100644 --- a/packages/tests/src/api/users/user-export.ts +++ b/packages/tests/src/api/users/user-export.ts @@ -852,6 +852,7 @@ function runTest (withObjectStorage: boolean) { await server.userExports.request({ userId: noahId, withVideoFiles: true }) await server.userExports.waitForCreation({ userId: noahId }) + await wait(1500) const tomorrow = new Date() tomorrow.setDate(tomorrow.getDate() + 1) @@ -866,6 +867,13 @@ function runTest (withObjectStorage: boolean) { await checkExportFileExists({ exists: true, server, userExport, withObjectStorage, redirectedUrl }) + // Should not delete the file + await server.debug.sendCommand({ body: { command: 'remove-expired-user-exports' } }) + // File deletion + await wait(500) + + await checkExportFileExists({ exists: true, server, userExport, withObjectStorage, redirectedUrl }) + await server.config.updateExistingConfig({ newConfig: { export: { @@ -876,11 +884,7 @@ function runTest (withObjectStorage: boolean) { } }) - await server.debug.sendCommand({ - body: { - command: 'remove-expired-user-exports' - } - }) + await server.debug.sendCommand({ body: { command: 'remove-expired-user-exports' } }) // File deletion await wait(500) diff --git a/server/core/models/user/user-export.ts b/server/core/models/user/user-export.ts index d791d893a..a54ee4e32 100644 --- a/server/core/models/user/user-export.ts +++ b/server/core/models/user/user-export.ts @@ -109,7 +109,7 @@ export class UserExportModel extends SequelizeModel { const query: FindOptions = { where: { createdAt: { - [Op.lt]: new Date(new Date().getTime() + expirationTimeMS) + [Op.lt]: new Date(new Date().getTime() - expirationTimeMS) } } }