The folder automation re-admitted a file every minute when the user had removed its jobs while a hoster was still missing, because nothing recorded the removal. Removing automatic jobs (selected, all, per hoster or through MCP) now stores the file path and identity in automation-dismissals.json. The automation skips such files until the file changes or the user adds it manually again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13178512bf
commit
f64fe23019
8 files changed
+176
-11
No files matched your search
+50
-1
@@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const secretStore = require('./secret-store');
|
||||
const { normalizeLogMode } = require('./log-mode');
|
||||
const { mergeAutomationCompletions, normalizeAutomationCompletion, removeAutomationCompletions } = require('./automation-control');
|
||||
const { mergeAutomationCompletions, normalizeAutomationCompletion, removeAutomationCompletions, mergeAutomationDismissals, removeAutomationDismissals } = require('./automation-control');
|
||||
|
||||
const TRANSIENT_RENAME_ERROR_CODES = new Set(['EPERM', 'EBUSY', 'EACCES']);
|
||||
const RENAME_RETRY_DELAYS_MS = [50, 100, 200, 400, 800, 1600, 3200];
|
||||
@@ -188,6 +188,9 @@ class ConfigStore {
|
||||
this.filePath = path.join(dir, 'electron-config.json');
|
||||
this.historyPath = path.join(dir, 'electron-history.json');
|
||||
this.automationCompletionPath = path.join(dir, 'automation-completions.json');
|
||||
this.automationDismissalPath = path.join(dir, 'automation-dismissals.json');
|
||||
this._automationDismissalWriteQueue = Promise.resolve();
|
||||
this._automationDismissalCache = null;
|
||||
this._writeQueue = Promise.resolve(); // Serializes all writes to prevent race conditions
|
||||
this._historyWriteQueue = Promise.resolve();
|
||||
this._automationCompletionWriteQueue = Promise.resolve();
|
||||
@@ -768,6 +771,52 @@ class ConfigStore {
|
||||
await this._automationCompletionWriteQueue;
|
||||
}
|
||||
|
||||
async _readAutomationDismissalFile() {
|
||||
try {
|
||||
const parsed = JSON.parse(await fs.promises.readFile(this.automationDismissalPath, 'utf8'));
|
||||
return mergeAutomationDismissals([], parsed && parsed.entries);
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') return [];
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async _writeAutomationDismissalFile(entries) {
|
||||
const target = this.automationDismissalPath;
|
||||
const temporary = `${target}.tmp`;
|
||||
await fs.promises.mkdir(path.dirname(target), { recursive: true });
|
||||
await fs.promises.writeFile(temporary, JSON.stringify({ version: 1, entries }), 'utf8');
|
||||
await this._renameWithRetry(temporary, target);
|
||||
}
|
||||
|
||||
_updateAutomationDismissals(update) {
|
||||
const result = this._automationDismissalWriteQueue.then(async () => {
|
||||
const current = this._automationDismissalCache || await this._readAutomationDismissalFile();
|
||||
const next = update(current);
|
||||
await this._writeAutomationDismissalFile(next);
|
||||
this._automationDismissalCache = next;
|
||||
return this._clone(next);
|
||||
});
|
||||
this._automationDismissalWriteQueue = result.catch(() => {});
|
||||
return result;
|
||||
}
|
||||
|
||||
async loadAutomationDismissals() {
|
||||
await this._automationDismissalWriteQueue;
|
||||
if (!this._automationDismissalCache) this._automationDismissalCache = await this._readAutomationDismissalFile();
|
||||
return this._clone(this._automationDismissalCache);
|
||||
}
|
||||
|
||||
addAutomationDismissals(entries) {
|
||||
const incoming = this._clone(Array.isArray(entries) ? entries : []);
|
||||
return this._updateAutomationDismissals(current => mergeAutomationDismissals(current, incoming));
|
||||
}
|
||||
|
||||
removeAutomationDismissals(paths) {
|
||||
const removed = Array.isArray(paths) ? paths.map(String) : [];
|
||||
return this._updateAutomationDismissals(current => removeAutomationDismissals(current, removed));
|
||||
}
|
||||
|
||||
saveLastBrowseDirectory(directory) {
|
||||
const snapshot = String(directory || '').trim();
|
||||
return this._enqueueWrite(async () => {
|
||||
|
||||
Reference in new issue
Block a user