fix(import): mark the archive as claimed when its job starts

sweepStaleTempUploads deletes temp uploads by mtime alone and its age
cutoff matches the job TTL, so a job confirmed just short of a day after
upload could have its archive removed mid-run. Touching the file when the
run claims it restarts the clock the sweep reads.
This commit is contained in:
Marco Beretta 2026-07-29 02:28:36 +02:00
parent 959b356a1c
commit a16a4a57d9
No known key found for this signature in database
GPG key ID: D918033D8E74CC11

View file

@ -378,6 +378,15 @@ function resolveJobTarget(job) {
*/
async function runImportJob(req, job) {
try {
/**
* `sweepStaleTempUploads` deletes temp uploads by mtime alone, and the job
* TTL matches its age cutoff so a job confirmed just short of a day after
* its upload would have its archive removed out from under the run. Marking
* the file as touched when the run claims it restarts that clock, which is
* the only signal the sweep can see.
*/
await fs.promises.utimes(job.filepath, new Date(), new Date()).catch(() => undefined);
const appConfig = req.config;
const source = getFileStrategy(appConfig, { isImage: true });
const { saveBuffer } = getStrategyFunctions(source);