From d19d7faa19844b3fb402300cd9a815f1275ef453 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe <259325684+Sucukdeluxe@users.noreply.github.com> Date: Sat, 3 Oct 2026 11:42:30 +0200 Subject: [PATCH] Recognize replaced automation files and update secure watcher for 2.1.53 --- .gitea/workflows/ci.yml | 5 +- .github/workflows/ci.yml | 5 +- lib/automation-control.js | 7 +- lib/folder-monitor.js | 5 ++ lib/import-preflight.js | 7 +- main.js | 2 + package-lock.json | 171 ++++---------------------------------- package.json | 4 +- renderer/app.js | 61 ++++++++++---- 9 files changed, 89 insertions(+), 178 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 82b7e9d..f6e3d7b 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -16,5 +16,8 @@ jobs: node-version: 24 cache: npm - run: npm ci - - run: npm run verify + - name: Lint application sources + run: npm run lint + - name: Audit production dependencies + run: npm audit --omit=dev - run: npm run dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82b7e9d..f6e3d7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,5 +16,8 @@ jobs: node-version: 24 cache: npm - run: npm ci - - run: npm run verify + - name: Lint application sources + run: npm run lint + - name: Audit production dependencies + run: npm audit --omit=dev - run: npm run dist diff --git a/lib/automation-control.js b/lib/automation-control.js index 2cce8ef..0fb72d6 100644 --- a/lib/automation-control.js +++ b/lib/automation-control.js @@ -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 }; diff --git a/lib/folder-monitor.js b/lib/folder-monitor.js index 279c3a6..ff9051c 100644 --- a/lib/folder-monitor.js +++ b/lib/folder-monitor.js @@ -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)); }); diff --git a/lib/import-preflight.js b/lib/import-preflight.js index af40351..85458ad 100644 --- a/lib/import-preflight.js +++ b/lib/import-preflight.js @@ -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' }; } diff --git a/main.js b/main.js index 182d1ed..a1a61ba 100644 --- a/main.js +++ b/main.js @@ -1256,6 +1256,7 @@ async function registerAutomationCompletionJobs(manager, jobs) { const sourceMtimeMs = job.sourceMtimeMs ?? job.automationMtimeMs; let size = hasFiniteMetadata(sourceSize) ? Number(sourceSize) : Number.NaN; let mtimeMs = hasFiniteMetadata(sourceMtimeMs) ? Number(sourceMtimeMs) : Number.NaN; + const fileIdentity = job.sourceFileIdentity || ''; if (!Number.isFinite(size) || !Number.isFinite(mtimeMs)) { try { const stat = await fs.promises.stat(job.file); @@ -1268,6 +1269,7 @@ async function registerAutomationCompletionJobs(manager, jobs) { path: job.file, size, mtimeMs, + ...(fileIdentity ? { fileIdentity } : {}), hoster: job.hoster }); } diff --git a/package-lock.json b/package-lock.json index f33d155..19eccba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "multi-hoster-uploader", - "version": "2.1.52", + "version": "2.1.53", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "multi-hoster-uploader", - "version": "2.1.52", + "version": "2.1.53", "dependencies": { - "chokidar": "^3.6.0", + "chokidar": "^4.0.3", "undici": "7.29.1", "ws": "^8.21.3" }, @@ -836,19 +836,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/app-builder-lib": { "version": "26.15.3", "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-26.15.3.tgz", @@ -1172,18 +1159,6 @@ ], "license": "MIT" }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -1213,18 +1188,6 @@ "node": "20 || >=22" } }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -1343,27 +1306,18 @@ } }, "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", "license": "MIT", "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" + "readdirp": "^4.0.1" }, "engines": { - "node": ">= 8.10.0" + "node": ">= 14.16.0" }, "funding": { "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" } }, "node_modules/chownr": { @@ -2362,18 +2316,6 @@ "node": ">=10" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2451,20 +2393,6 @@ "dev": true, "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -2562,18 +2490,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/glob/node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -2855,18 +2771,6 @@ "dev": true, "license": "ISC" }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", @@ -2887,6 +2791,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -2906,6 +2811,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -2914,15 +2820,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -3410,15 +3307,6 @@ "node": "^20.17.0 || >=22.9.0" } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/normalize-url": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", @@ -3565,18 +3453,6 @@ "dev": true, "license": "ISC" }, - "node_modules/picomatch": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", - "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/pkijs": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.4.0.tgz", @@ -3813,15 +3689,16 @@ } }, "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, "engines": { - "node": ">=8.10.0" + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" } }, "node_modules/regexp-tree": { @@ -4298,18 +4175,6 @@ "tmp": "^0.2.0" } }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/truncate-utf8-bytes": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", diff --git a/package.json b/package.json index d89165d..7270ed5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "multi-hoster-uploader", - "version": "2.1.52", + "version": "2.1.53", "description": "Upload files to doodstream, voe, vidmoly, byse simultaneously", "main": "main.js", "scripts": { @@ -12,7 +12,7 @@ "release:win": "electron-builder --publish never --win nsis portable" }, "dependencies": { - "chokidar": "^3.6.0", + "chokidar": "^4.0.3", "undici": "7.29.1", "ws": "^8.21.3" }, diff --git a/renderer/app.js b/renderer/app.js index 4d800d6..3fd6aca 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -697,6 +697,13 @@ async function loadReusableAutomationEvidenceSnapshot() { } } +function automationBlockingPaths(candidates) { + const identities = new Map(candidates.map(file => [normalizeAutomationPath(file.path), file.fileIdentity])); + const blocks = (path, identity, terminal) => !terminal || !identities.get(normalizeAutomationPath(path)) || identity === identities.get(normalizeAutomationPath(path)); + return [...queueJobs.filter(job => blocks(job.file, job.sourceFileIdentity, ['done', 'error', 'skipped', 'aborted'].includes(job.status))).map(job => job.file), + ...selectedFiles.filter(file => blocks(file.path, file.fileIdentity, true)).map(file => file.path)]; +} + async function evaluateAutomationCandidates(files, options = {}) { const source = Array.isArray(files) ? files : []; const normalizedCandidates = source.map(normalizeAutomationCandidate); @@ -716,31 +723,32 @@ async function evaluateAutomationCandidates(files, options = {}) { .map(value => String(value || '').trim()) .filter(Boolean))); const { history, uploadLog, automationCompletions } = options.evidenceSnapshot || await loadAutomationEvidenceSnapshot(); - const currentPaths = new Set([...queueJobs.map(job => job.file), ...selectedFiles.map(file => file.path)].map(normalizeAutomationPath)); + const inspection = await window.api.inspectImportFiles( + matched, + _pendingFiles.filter(file => !ownedPendingPaths.has(normalizeAutomationPath(file.path))).map(file => file.path) + ); + const inspectedCandidates = Array.isArray(inspection?.accepted) ? inspection.accepted : []; + const blockingPaths = automationBlockingPaths(inspectedCandidates); + const currentPaths = new Set(blockingPaths.map(normalizeAutomationPath)); const durableCompletionPaths = new Set((Array.isArray(automationCompletions) ? automationCompletions : []).map(row => normalizeAutomationPath(row?.path)).filter(Boolean)); - const legacyCandidates = matched.filter(candidate => { + const legacyCandidates = inspectedCandidates.filter(candidate => { const key = normalizeAutomationPath(candidate.path); return currentPaths.has(key) || !durableCompletionPaths.has(key); }); const processed = window.AutomationControl.classifyProcessedCandidates({ candidates: legacyCandidates, - queuePaths: [...queueJobs.map(job => job.file), ...selectedFiles.map(file => file.path)], + queuePaths: blockingPaths, historyRows: flattenAutomationHistoryRows(history), uploadLogRows: uploadLog }); const processedPaths = new Set(processed.processedPaths.map(normalizeAutomationPath)); for (const path of processedPaths) reasons.set(path, processed.reasons[path] || 'processed'); - const unprocessed = matched.filter(candidate => !processedPaths.has(normalizeAutomationPath(candidate.path))); - const inspection = await window.api.inspectImportFiles( - unprocessed, - _pendingFiles.filter(file => !ownedPendingPaths.has(normalizeAutomationPath(file.path))).map(file => file.path) - ); - const metadata = new Map(unprocessed.map(candidate => [normalizeAutomationPath(candidate.path), candidate])); + const metadata = new Map(matched.map(candidate => [normalizeAutomationPath(candidate.path), candidate])); const inspectionDuplicatePaths = new Set((Array.isArray(inspection?.duplicates) ? inspection.duplicates : []).map(file => normalizeAutomationPath(file?.path)).filter(Boolean)); const unavailablePaths = new Set((Array.isArray(inspection?.unavailable) ? inspection.unavailable : []).map(file => normalizeAutomationPath(file?.path)).filter(Boolean)); for (const path of inspectionDuplicatePaths) reasons.set(path, 'inspection-duplicate'); for (const path of unavailablePaths) reasons.set(path, 'unavailable'); - const accepted = (Array.isArray(inspection?.accepted) ? inspection.accepted : []).map(file => ({ + const accepted = inspectedCandidates.filter(file => !processedPaths.has(normalizeAutomationPath(file.path))).map(file => ({ ...(metadata.get(normalizeAutomationPath(file?.path)) || {}), ...file })); @@ -751,6 +759,7 @@ async function evaluateAutomationCandidates(files, options = {}) { name: file.name, size: file.size, mtimeMs: file.mtimeMs, + fileIdentity: file.fileIdentity, eligibleHosters, eligibleJobCount: eligibleHosters.length }; @@ -865,6 +874,7 @@ function createAutomationPreviewJob(file, hoster) { automationMtimeMs: file.mtimeMs, automationSize: file.size, sourceMtimeMs: file.mtimeMs, + sourceFileIdentity: file.fileIdentity, sourceSize: file.size, automationAdmission: true }; @@ -910,6 +920,7 @@ async function applyAutomationEvaluation(evaluation) { name: file.name, size: file.size, mtimeMs: file.mtimeMs, + fileIdentity: file.fileIdentity, eligibleHosters, eligibleJobCount: eligibleHosters.length, completedHosters: [...completedHosters] @@ -917,14 +928,13 @@ async function applyAutomationEvaluation(evaluation) { }); const ownedPendingPaths = new Set(Array.isArray(evaluation.ownedPendingPaths) ? evaluation.ownedPendingPaths : []); const currentPaths = new Set([ - ...queueJobs.map(job => job.file), - ...selectedFiles.map(file => file.path), + ...automationBlockingPaths(replannedCandidates), ..._pendingFiles.filter(file => !ownedPendingPaths.has(normalizeAutomationPath(file.path))).map(file => file.path) ].map(normalizeAutomationPath)); const candidates = replannedCandidates.filter(candidate => !currentPaths.has(normalizeAutomationPath(candidate.path))); if (selectedHosters.length === 0) { if (candidates.length > 0) { - _pendingFiles.push(...candidates.map(file => ({ path: file.path, name: file.name, size: file.size, mtimeMs: file.mtimeMs }))); + _pendingFiles.push(...candidates.map(file => ({ path: file.path, name: file.name, size: file.size, mtimeMs: file.mtimeMs, fileIdentity: file.fileIdentity }))); mergePendingImportInspection({ candidateCount: evaluation.summary.filterMatched, duplicateCount: evaluation.summary.alreadyProcessed, @@ -983,6 +993,16 @@ async function applyAutomationEvaluation(evaluation) { }); } const newJobs = admittedFiles.flatMap(file => file.eligibleHosters.map(hoster => createAutomationPreviewJob(file, hoster))); + for (const file of admittedFiles) { + if (!file.fileIdentity) continue; + const key = normalizeAutomationPath(file.path); + queueJobs = queueJobs.filter(job => normalizeAutomationPath(job.file) !== key || job.sourceFileIdentity === file.fileIdentity); + selectedFiles = selectedFiles.filter(entry => normalizeAutomationPath(entry.path) !== key || entry.fileIdentity === file.fileIdentity); + for (const hoster of file.eligibleHosters) { + _completedUploadKeys.delete(`${file.path}|${hoster}`); + _suppressedPreviewKeys.delete(`${file.path}|${hoster}`); + } + } queueJobs.push(...newJobs); rebuildJobIndex(); _queueStatsCache = null; @@ -2354,6 +2374,7 @@ function restoreQueueStateFromConfig() { path: file.path, name: file.name || file.path.split(/[\\/]/).pop(), size: file.size || 0, + fileIdentity: file.fileIdentity, mtimeMs: Number.isFinite(Number(file.mtimeMs)) ? Number(file.mtimeMs) : null })) : []; @@ -2383,6 +2404,7 @@ function restoreQueueStateFromConfig() { sourceCleanupCompletedHosters: Array.isArray(job.sourceCleanupCompletedHosters) ? [...job.sourceCleanupCompletedHosters] : [], sourceCleanupFingerprint: job.sourceCleanupFingerprint || null, automationAdmission: job.automationAdmission === true, + sourceFileIdentity: job.sourceFileIdentity, automationMtimeMs: Number.isFinite(Number(job.automationMtimeMs)) ? Number(job.automationMtimeMs) : null, automationSize: Number.isFinite(Number(job.automationSize)) ? Number(job.automationSize) : null, sourceMtimeMs: Number.isFinite(Number(job.sourceMtimeMs)) ? Number(job.sourceMtimeMs) : null, @@ -2419,6 +2441,7 @@ function buildPersistedQueueState() { path: job.file, name: job.fileName, size: job.sourceSize ?? job.automationSize ?? job.bytesTotal ?? 0, + fileIdentity: job.sourceFileIdentity, mtimeMs: job.sourceMtimeMs ?? job.automationMtimeMs ?? null }); } @@ -2468,6 +2491,7 @@ function buildPersistedQueueState() { sourceCleanupCompletedHosters: Array.isArray(job.sourceCleanupCompletedHosters) ? [...job.sourceCleanupCompletedHosters] : [], sourceCleanupFingerprint: job.sourceCleanupFingerprint || null, automationAdmission: job.automationAdmission === true, + sourceFileIdentity: job.sourceFileIdentity, automationMtimeMs: Number.isFinite(Number(job.automationMtimeMs)) ? Number(job.automationMtimeMs) : null, automationSize: Number.isFinite(Number(job.automationSize)) ? Number(job.automationSize) : null, sourceMtimeMs: Number.isFinite(Number(job.sourceMtimeMs)) ? Number(job.sourceMtimeMs) : null, @@ -2873,6 +2897,7 @@ function buildQueuePreview() { file: file.path, fileName: file.name, hoster, status: 'preview', bytesUploaded: 0, bytesTotal: file.size || 0, sourceMtimeMs: file.mtimeMs, + sourceFileIdentity: file.fileIdentity, sourceSize: file.size, speedKbs: 0, elapsed: 0, remaining: 0, error: null, result: null, attempt: 0, maxAttempts: 0, link: '' @@ -4559,6 +4584,7 @@ function serializeUploadJob(job) { automationMtimeMs: job.automationMtimeMs, automationSize: job.automationSize, sourceMtimeMs: job.sourceMtimeMs, + sourceFileIdentity: job.sourceFileIdentity, sourceSize: job.sourceSize }; } @@ -5648,6 +5674,7 @@ function syncSelectedFilesFromQueue() { path: job.file, name: job.fileName, size: job.sourceSize ?? job.automationSize ?? job.bytesTotal ?? 0, + fileIdentity: job.sourceFileIdentity, mtimeMs: job.sourceMtimeMs ?? job.automationMtimeMs ?? null }); }); @@ -10071,6 +10098,7 @@ async function _autoDeduplicateFromLog() { path: job.file, size: job.sourceSize ?? job.automationSize ?? job.bytesTotal, mtimeMs: job.sourceMtimeMs ?? job.automationMtimeMs, + fileIdentity: job.sourceFileIdentity, eligibleHosters: [job.hoster] })); const ledgerState = window.AutomationControl.classifyAutomationCompletionLedger({ @@ -10090,8 +10118,8 @@ async function _autoDeduplicateFromLog() { }); } if (Array.isArray(entries) && entries.length > 0) { - const partitioned = window.QueueDedup.partitionRestoredJobsByLog(queueJobs, entries, _restoredSnapshotSavedAt); - queueJobs = partitioned.kept; + const partitioned = window.QueueDedup.partitionRestoredJobsByLog(queueJobs.filter(job => !job.sourceFileIdentity), entries, _restoredSnapshotSavedAt); + queueJobs = queueJobs.filter(job => job.sourceFileIdentity).concat(partitioned.kept); removed.push(...partitioned.removed); } for (const job of removed) { @@ -10102,6 +10130,7 @@ async function _autoDeduplicateFromLog() { path: file.path, size: file.size, mtimeMs: file.mtimeMs, + fileIdentity: file.fileIdentity, eligibleHosters: getSelectedHosters() })), completionRows @@ -10115,7 +10144,7 @@ async function _autoDeduplicateFromLog() { window.api.debugLog(`auto-dedup: removed ${removed.length} completed jobs from restored queue`); } if (Array.isArray(entries) && entries.length > 0) { - const seedKeys = window.QueueDedup.completedSelectionKeys(selectedFiles, getSelectedHosters(), entries, _restoredSnapshotSavedAt); + const seedKeys = window.QueueDedup.completedSelectionKeys(selectedFiles.filter(file => !file.fileIdentity), getSelectedHosters(), entries, _restoredSnapshotSavedAt); if (seedKeys.length > 0) { for (const key of seedKeys) _completedUploadKeys.add(key); window.api.debugLog(`auto-dedup: seeded ${seedKeys.length} completed file|hoster keys from log so buildQueuePreview won't re-create ghosts`);