Fix user export expiration

This commit is contained in:
Chocobozzz 2024-12-16 07:11:30 +01:00
parent aac9ff8931
commit ae3b487c42
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 10 additions and 6 deletions

View File

@ -852,6 +852,7 @@ function runTest (withObjectStorage: boolean) {
await server.userExports.request({ userId: noahId, withVideoFiles: true }) await server.userExports.request({ userId: noahId, withVideoFiles: true })
await server.userExports.waitForCreation({ userId: noahId }) await server.userExports.waitForCreation({ userId: noahId })
await wait(1500)
const tomorrow = new Date() const tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1) tomorrow.setDate(tomorrow.getDate() + 1)
@ -866,6 +867,13 @@ function runTest (withObjectStorage: boolean) {
await checkExportFileExists({ exists: true, server, userExport, withObjectStorage, redirectedUrl }) 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({ await server.config.updateExistingConfig({
newConfig: { newConfig: {
export: { export: {
@ -876,11 +884,7 @@ function runTest (withObjectStorage: boolean) {
} }
}) })
await server.debug.sendCommand({ await server.debug.sendCommand({ body: { command: 'remove-expired-user-exports' } })
body: {
command: 'remove-expired-user-exports'
}
})
// File deletion // File deletion
await wait(500) await wait(500)

View File

@ -109,7 +109,7 @@ export class UserExportModel extends SequelizeModel<UserExportModel> {
const query: FindOptions = { const query: FindOptions = {
where: { where: {
createdAt: { createdAt: {
[Op.lt]: new Date(new Date().getTime() + expirationTimeMS) [Op.lt]: new Date(new Date().getTime() - expirationTimeMS)
} }
} }
} }