fix: harden automation reconciliation and pause lifecycle

Keep full folder scans recoverable under duplicate protection and classify every discovered file once before automatic admission.

Separate manual previews from automatic capacity limits, serialize renderer intake, normalize automation counters and intervals, and make Main authoritative for runtime timestamps.

Enforce persistent pause across startup, import, close recovery, resume failures, and reconciliation while preserving read-only paused scans and exactly one activation reconciliation.

Restore failed asynchronous rotation chunks, complete automation localization and unlimited queue accessibility, and tighten hidden integration cleanup coverage.
This commit is contained in:
Sucukdeluxe
2026-08-26 15:47:31 +02:00
parent ca2d1f8fda
commit afd3b70cf3
12 changed files with 812 additions and 157 deletions
+54 -1
View File
@@ -105,8 +105,61 @@ function createUploadAuditWriter(options) {
return createInternalLogWriter({ ...options, fileName: 'upload-audit.log' });
}
function createBufferedInternalLogFlusher(options) {
const source = options && typeof options === 'object' ? options : {};
const buffer = source.buffer;
const writer = source.writer;
const schedule = typeof source.schedule === 'function' ? source.schedule : setImmediate;
const reportError = typeof source.reportError === 'function' ? source.reportError : () => {};
let writing = false;
if (!Array.isArray(buffer) || !writer || typeof writer.append !== 'function' || typeof writer.flushSync !== 'function') {
throw new TypeError('createBufferedInternalLogFlusher requires buffer and writer');
}
function restoreChunk(chunk) {
for (let end = chunk.length; end > 0;) {
const start = Math.max(0, end - 1024);
buffer.splice(0, 0, ...chunk.slice(start, end));
end = start;
}
}
async function flush(label) {
if (writing || buffer.length === 0) return null;
const chunk = buffer.splice(0);
writing = true;
let written = false;
try {
written = await writer.append(chunk.join(''), label);
} catch (error) {
reportError(label, error);
} finally {
writing = false;
}
if (!written) {
restoreChunk(chunk);
return false;
}
if (buffer.length > 0) {
try {
schedule(() => { void flush(label); });
} catch (error) {
reportError(label, error);
}
}
return true;
}
return {
flush,
flushSync: label => writer.flushSync(buffer, label),
isWriting: () => writing
};
}
function getLogOpenDirectory(targetPath, fallbackDirectory, pathApi = nodePath) {
return typeof targetPath === 'string' && targetPath ? pathApi.dirname(targetPath) : fallbackDirectory;
}
module.exports = { createInternalLogPathResolver, createInternalLogWriter, createUploadAuditWriter, getLogOpenDirectory };
module.exports = { createInternalLogPathResolver, createInternalLogWriter, createUploadAuditWriter, createBufferedInternalLogFlusher, getLogOpenDirectory };