Verify update artifacts with exact metadata and SHA-512, require host-confirmed upload completion before cleanup, harden credentials and backups, improve queue recovery and skipped-state reporting, expand Windows path coverage, and add CI packaging checks.
This commit is contained in:
+18
-3
@@ -3,13 +3,15 @@ const path = require('path');
|
||||
const chokidar = require('chokidar');
|
||||
|
||||
class FolderMonitor extends EventEmitter {
|
||||
constructor() {
|
||||
constructor({ watch = chokidar.watch } = {}) {
|
||||
super();
|
||||
this._watch = watch;
|
||||
this._watcher = null;
|
||||
this._settings = null;
|
||||
this._seenFiles = new Set();
|
||||
this._batchBuffer = [];
|
||||
this._batchTimer = null;
|
||||
this._initialScopes = new Set();
|
||||
}
|
||||
|
||||
get running() {
|
||||
@@ -23,9 +25,18 @@ class FolderMonitor extends EventEmitter {
|
||||
const folderPath = String(settings.folderPath || '').trim();
|
||||
if (!folderPath) throw new Error('Kein Ordnerpfad angegeben');
|
||||
|
||||
const scope = JSON.stringify([
|
||||
path.resolve(folderPath).toLowerCase(),
|
||||
!!settings.recursive,
|
||||
String(settings.filterMode || 'include'),
|
||||
String(settings.extensions || '').trim().toLowerCase()
|
||||
]);
|
||||
const includeInitial = !!settings.includeExisting && !this._initialScopes.has(scope);
|
||||
if (includeInitial) this._initialScopes.add(scope);
|
||||
|
||||
const watchOptions = {
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
ignoreInitial: !includeInitial,
|
||||
depth: settings.recursive ? undefined : 0,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: Math.max(1000, (settings.delaySec || 3) * 1000),
|
||||
@@ -33,7 +44,10 @@ class FolderMonitor extends EventEmitter {
|
||||
}
|
||||
};
|
||||
|
||||
this._watcher = chokidar.watch(folderPath, watchOptions);
|
||||
this._watcher = this._watch(folderPath, watchOptions);
|
||||
if (includeInitial) {
|
||||
this._watcher.once('ready', () => this.emit('initial-scan-complete'));
|
||||
}
|
||||
this._watcher.on('add', (filePath) => this._onNewFile(filePath));
|
||||
this._watcher.on('unlink', (filePath) => {
|
||||
// Allow re-added files (e.g. re-encoded) to be detected again
|
||||
@@ -41,6 +55,7 @@ class FolderMonitor extends EventEmitter {
|
||||
this._seenFiles.delete(normalized);
|
||||
});
|
||||
this._watcher.on('error', (err) => this.emit('error', err));
|
||||
return { includesExisting: includeInitial };
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
Reference in New Issue
Block a user