Make media cleanup task respect timezone

This commit is contained in:
Laura Hausmann 2023-08-03 00:09:17 +02:00
parent 079942eda4
commit ed2622344f
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -14,12 +14,12 @@ export default async function cleanRemoteFiles(
done: any, done: any,
): Promise<void> { ): Promise<void> {
let progress = 0; let progress = 0;
let until = new Date(); let until = new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000));
until.setDate(until.getDate() - (config.mediaCleanup?.maxAgeDays ?? 0)); until.setDate(until.getDate() - (config.mediaCleanup?.maxAgeDays ?? 0));
const avatars = config.mediaCleanup?.avatars ?? false; const avatars = config.mediaCleanup?.avatars ?? false;
const headers = config.mediaCleanup?.headers ?? false; const headers = config.mediaCleanup?.headers ?? false;
until = until.toISOString().replace("T", " ").replace("Z", ""); until = until.toISOString().replace("T", " ").slice(0, -1);
let target = "files"; let target = "files";
if (avatars) if (avatars)