Recognize replaced automation files and update secure watcher for 2.1.53
CI / verify (push) Canceled after 0s
CI / verify (push) Canceled after 0s
This commit is contained in:
1 parent
f2e400c89e
commit
d19d7faa19
9 files changed
+89
-178
No files matched your search
@@ -170,6 +170,7 @@
|
||||
return {
|
||||
path,
|
||||
size,
|
||||
...(typeof row.fileIdentity === 'string' && row.fileIdentity ? { fileIdentity: row.fileIdentity } : {}),
|
||||
mtimeMs: Math.trunc(mtimeMs),
|
||||
hoster,
|
||||
completedAt: Number.isFinite(completedAt) && completedAt >= 0 ? Math.trunc(completedAt) : 0
|
||||
@@ -230,7 +231,7 @@
|
||||
const remaining = [];
|
||||
for (const hoster of hosters) {
|
||||
const row = rows.get(`${normalizePath(path)}\u0000${hoster}`);
|
||||
if (row && Number.isFinite(size) && size === row.size && Number.isFinite(mtimeMs) && Math.trunc(mtimeMs) === row.mtimeMs) completed.push(hoster);
|
||||
if (row && (!candidate.fileIdentity || candidate.fileIdentity === row.fileIdentity) && Number.isFinite(size) && size === row.size && Number.isFinite(mtimeMs) && Math.trunc(mtimeMs) === row.mtimeMs) completed.push(hoster);
|
||||
else remaining.push(hoster);
|
||||
}
|
||||
if (hosters.length > 0 && remaining.length === 0) processedPaths.push(path);
|
||||
@@ -316,11 +317,11 @@
|
||||
if (exact && queuePaths.has(exact)) {
|
||||
processedPaths.push(candidate?.path);
|
||||
reasons[exact] = 'in-queue';
|
||||
} else if ((exact && exactPaths.has(exact)) || (evidenceNames.has(name) && nameCounts.get(name) === 1)) {
|
||||
} else if (!candidate.fileIdentity && ((exact && exactPaths.has(exact)) || (evidenceNames.has(name) && nameCounts.get(name) === 1))) {
|
||||
processedPaths.push(candidate?.path);
|
||||
reasons[exact] = exactPaths.has(exact) || historyNames.has(name) ? 'history' : 'upload-log';
|
||||
}
|
||||
else if (evidenceNames.has(name) && nameCounts.get(name) > 1) ambiguousPaths.push(candidate?.path);
|
||||
else if (!candidate.fileIdentity && evidenceNames.has(name) && nameCounts.get(name) > 1) ambiguousPaths.push(candidate?.path);
|
||||
else unprocessedPaths.push(candidate?.path);
|
||||
}
|
||||
return { processedPaths, ambiguousPaths, unprocessedPaths, reasons };
|
||||
|
||||
@@ -192,6 +192,11 @@ class FolderMonitor extends EventEmitter {
|
||||
});
|
||||
}
|
||||
this._watcher.on('add', (filePath) => this._onNewFile(filePath, generation));
|
||||
this._watcher.on('change', (filePath) => {
|
||||
if (!this._acceptCallback(generation)) return;
|
||||
this._seenFiles.delete(this._normalizePath(filePath));
|
||||
this._onNewFile(filePath, generation);
|
||||
});
|
||||
this._watcher.on('unlink', (filePath) => {
|
||||
if (this._acceptCallback(generation)) this._seenFiles.delete(this._normalizePath(filePath));
|
||||
});
|
||||
|
||||
@@ -64,7 +64,10 @@
|
||||
fileHandle = await openPath(filePath, 'r');
|
||||
const fileStat = await fileHandle.stat();
|
||||
if (!fileStat.isFile()) return { exists: true, readable: false, size: fileStat.size, mtimeMs: fileStat.mtimeMs };
|
||||
return { exists: true, readable: true, size: fileStat.size, mtimeMs: fileStat.mtimeMs };
|
||||
const identityParts = [fileStat.dev, fileStat.ino, fileStat.birthtimeMs, fileStat.ctimeMs];
|
||||
const fileIdentity = identityParts.every(value => typeof value === 'number' && Number.isFinite(value))
|
||||
? `v1:${identityParts.join(':')}` : '';
|
||||
return { exists: true, readable: true, size: fileStat.size, mtimeMs: fileStat.mtimeMs, ...(fileIdentity ? { fileIdentity } : {}) };
|
||||
} catch (error) {
|
||||
if (error && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) return { exists: false };
|
||||
return { exists: true, readable: false };
|
||||
@@ -112,7 +115,7 @@
|
||||
const reason = unavailableReason(result);
|
||||
const mtimeMs = Number.isFinite(Number(result?.mtimeMs)) ? Number(result.mtimeMs) : entry.mtimeMs;
|
||||
if (reason) return { entry: { ...entry, size: Number(result?.size) || 0, mtimeMs }, reason };
|
||||
return { entry: { ...entry, size: Number(result.size), mtimeMs }, reason: '' };
|
||||
return { entry: { ...entry, size: Number(result.size), mtimeMs, ...(result.fileIdentity ? { fileIdentity: result.fileIdentity } : {}) }, reason: '' };
|
||||
} catch (error) {
|
||||
return { entry, reason: error && error.code === 'ENOENT' ? 'missing' : 'unreadable' };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user