Deleting a source after a successful upload first renames it to .<name>.mhu-delete-<uuid> and then unlinks it. On a slow disk the unlink can take several seconds. With an empty extension filter the folder watcher and the reconcile scan reported the staged file as a new file, so the automation queued and uploaded it again until the unlink removed it. The jobs for the vanished staged file were then restarted by every automatic start and skipped with "Datei nicht gefunden". - source-cleanup-policy: shared stagedSourceName/isStagedSourceFile. - folder-monitor and file-discovery skip staged delete files. - Automatic starts no longer restart queue jobs that point at a staged delete file; manual starts are unchanged. - An ENOENT while unlinking the staged file counts as deleted instead of a failed unlink with a restore attempt. EBUSY/EPERM keep their retries and stay visible as failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c7ce614a1
commit
23fc22fd7d
5 files changed
+23
-3
No files matched your search
@@ -1,6 +1,7 @@
|
||||
const RETRY_DELAYS = [100, 250, 500, 1000, 2000];
|
||||
const TERMINAL_STATUSES = new Set(['done', 'error', 'aborted', 'skipped', 'failed', 'missing-account']);
|
||||
const crypto = require('node:crypto');
|
||||
const { stagedSourceName } = require('./source-cleanup-policy');
|
||||
|
||||
function createSourceFileCleanup(options) {
|
||||
if (!options || !options.fs || !options.path) {
|
||||
@@ -322,6 +323,7 @@ function createSourceFileCleanup(options) {
|
||||
await fs.promises.unlink(file);
|
||||
return { attempts };
|
||||
} catch (error) {
|
||||
if (error && error.code === 'ENOENT') return { attempts, alreadyRemoved: true };
|
||||
const retryable = platform === 'win32' && error && (error.code === 'EBUSY' || error.code === 'EPERM');
|
||||
if (!retryable || attempts > RETRY_DELAYS.length) throw Object.assign(error, { cleanupAttempts: attempts });
|
||||
await wait(RETRY_DELAYS[attempts - 1]);
|
||||
@@ -346,7 +348,7 @@ function createSourceFileCleanup(options) {
|
||||
async function stageSource(manifest) {
|
||||
const stagedFile = path.join(
|
||||
path.dirname(manifest.file),
|
||||
`.${path.basename(manifest.file)}.mhu-delete-${crypto.randomUUID()}`
|
||||
stagedSourceName(path.basename(manifest.file), crypto.randomUUID())
|
||||
);
|
||||
if (!journal || typeof journal.plan !== 'function') {
|
||||
return { outcome: 'blocked', trigger: 'delete-journal-unavailable' };
|
||||
@@ -464,6 +466,7 @@ function createSourceFileCleanup(options) {
|
||||
await emitAudit(manifest, 'deleted', {
|
||||
trigger: 'all-selected-hosters-succeeded',
|
||||
attempts: result.attempts,
|
||||
...(result.alreadyRemoved ? { alreadyRemoved: true } : {}),
|
||||
...scope
|
||||
});
|
||||
return 'deleted';
|
||||
|
||||
Reference in new issue
Block a user