CI / verify (push) Canceled after 0s
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>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { isStagedSourceFile } = require('./source-cleanup-policy');
|
|
|
|
async function walkFolderAsync(rootDir, options = {}) {
|
|
const fsPromises = options.fsPromises || fs.promises;
|
|
const pathImpl = options.pathImpl || path;
|
|
const yieldFn = options.yieldFn || (() => new Promise(setImmediate));
|
|
const recursive = options.recursive !== false;
|
|
const files = [];
|
|
const stack = [rootDir];
|
|
let scanned = 0;
|
|
|
|
while (stack.length > 0) {
|
|
const dir = stack.pop();
|
|
let entries;
|
|
try {
|
|
entries = await fsPromises.readdir(dir, { withFileTypes: true });
|
|
} catch {
|
|
continue;
|
|
}
|
|
for (const entry of entries) {
|
|
const fullPath = pathImpl.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
if (recursive) stack.push(fullPath);
|
|
} else if (entry.isFile() && !isStagedSourceFile(entry.name)) {
|
|
let size = 0;
|
|
try {
|
|
size = (await fsPromises.stat(fullPath)).size;
|
|
} catch {}
|
|
files.push({ path: fullPath, name: entry.name, size });
|
|
}
|
|
}
|
|
scanned++;
|
|
if (scanned % 8 === 0) await yieldFn();
|
|
}
|
|
|
|
return files;
|
|
}
|
|
|
|
module.exports = { walkFolderAsync };
|