fix: clean up temp segment directory after conform job finishes
This commit is contained in:
parent
90bb0769e5
commit
b175eaf54c
1 changed files with 3 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { unlink, writeFile, mkdir } from 'fs/promises';
|
import { unlink, writeFile, mkdir, rm } from 'fs/promises';
|
||||||
import { tmpdir } from 'os';
|
import { tmpdir } from 'os';
|
||||||
import { query } from '../db/client.js';
|
import { query } from '../db/client.js';
|
||||||
import { downloadFromS3, uploadToS3 } from '../s3/client.js';
|
import { downloadFromS3, uploadToS3 } from '../s3/client.js';
|
||||||
|
|
@ -97,11 +97,12 @@ export const conformWorker = async (job) => {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// Best-effort cleanup of temp files
|
// Best-effort cleanup of all temp files and directories
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
unlink(edlPath).catch(() => {}),
|
unlink(edlPath).catch(() => {}),
|
||||||
unlink(segmentListPath).catch(() => {}),
|
unlink(segmentListPath).catch(() => {}),
|
||||||
unlink(outputPath).catch(() => {}),
|
unlink(outputPath).catch(() => {}),
|
||||||
|
rm(segmentsDir, { recursive: true, force: true }).catch(() => {}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue