Compare commits
No commits in common. "d601bd7986b8efc6c06a05c090774be99926281b" and "9ea92126372a7e6e029d669858cb1a9c4f23a1e9" have entirely different histories.
d601bd7986
...
9ea9212637
@ -94,7 +94,6 @@ class ConfigStore {
|
|||||||
? app.getPath('userData')
|
? app.getPath('userData')
|
||||||
: path.join(__dirname, '..');
|
: path.join(__dirname, '..');
|
||||||
this.filePath = path.join(dir, 'electron-config.json');
|
this.filePath = path.join(dir, 'electron-config.json');
|
||||||
this._writeQueue = Promise.resolve(); // Serializes all writes to prevent race conditions
|
|
||||||
|
|
||||||
// Migrate config from old location if current doesn't exist
|
// Migrate config from old location if current doesn't exist
|
||||||
if (!fs.existsSync(this.filePath) && app && app.isPackaged) {
|
if (!fs.existsSync(this.filePath) && app && app.isPackaged) {
|
||||||
@ -209,19 +208,12 @@ class ConfigStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_enqueueWrite(fn) {
|
|
||||||
this._writeQueue = this._writeQueue.then(fn, fn);
|
|
||||||
return this._writeQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
save(config) {
|
save(config) {
|
||||||
return this._enqueueWrite(() => {
|
|
||||||
const current = this.load();
|
const current = this.load();
|
||||||
if (config.hosters) current.hosters = config.hosters;
|
if (config.hosters) current.hosters = config.hosters;
|
||||||
if (config.hosterSettings) current.hosterSettings = config.hosterSettings;
|
if (config.hosterSettings) current.hosterSettings = config.hosterSettings;
|
||||||
if (config.globalSettings) current.globalSettings = config.globalSettings;
|
if (config.globalSettings) current.globalSettings = config.globalSettings;
|
||||||
return this._atomicWrite(JSON.stringify(current, null, 2));
|
return this._atomicWrite(JSON.stringify(current, null, 2));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHistory() {
|
loadHistory() {
|
||||||
@ -250,22 +242,18 @@ class ConfigStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
appendHistory(entry) {
|
appendHistory(entry) {
|
||||||
return this._enqueueWrite(() => {
|
|
||||||
const config = this.load();
|
const config = this.load();
|
||||||
config.history.push(entry);
|
config.history.push(entry);
|
||||||
if (config.history.length > MAX_HISTORY) {
|
if (config.history.length > MAX_HISTORY) {
|
||||||
config.history = config.history.slice(-MAX_HISTORY);
|
config.history = config.history.slice(-MAX_HISTORY);
|
||||||
}
|
}
|
||||||
return this._atomicWrite(JSON.stringify(config, null, 2));
|
return this._atomicWrite(JSON.stringify(config, null, 2));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clearHistory() {
|
clearHistory() {
|
||||||
return this._enqueueWrite(() => {
|
|
||||||
const config = this.load();
|
const config = this.load();
|
||||||
config.history = [];
|
config.history = [];
|
||||||
return this._atomicWrite(JSON.stringify(config, null, 2));
|
return this._atomicWrite(JSON.stringify(config, null, 2));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
main.js
14
main.js
@ -502,8 +502,7 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
// Auto-start remote server if enabled
|
// Auto-start remote server if enabled
|
||||||
try {
|
try {
|
||||||
const _remCfg = configStore.load();
|
const remoteConfig = configStore.load().globalSettings && configStore.load().globalSettings.remote;
|
||||||
const remoteConfig = _remCfg.globalSettings && _remCfg.globalSettings.remote;
|
|
||||||
if (remoteConfig && remoteConfig.enabled) {
|
if (remoteConfig && remoteConfig.enabled) {
|
||||||
startRemoteServer().catch(err => {
|
startRemoteServer().catch(err => {
|
||||||
debugLog(`remote-server auto-start failed: ${err.message}`);
|
debugLog(`remote-server auto-start failed: ${err.message}`);
|
||||||
@ -541,7 +540,6 @@ app.on('window-all-closed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on('before-quit', () => {
|
app.on('before-quit', () => {
|
||||||
if (uploadManager) try { uploadManager.cancel(); } catch {}
|
|
||||||
try { folderMonitor.stop(); } catch {}
|
try { folderMonitor.stop(); } catch {}
|
||||||
try {
|
try {
|
||||||
if (remoteServer) { remoteServer.stop(); remoteServer = null; }
|
if (remoteServer) { remoteServer.stop(); remoteServer = null; }
|
||||||
@ -876,16 +874,6 @@ ipcMain.handle('save-global-settings', async (_event, globalSettings) => {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Synchronous save for beforeunload — blocks renderer until write completes
|
|
||||||
ipcMain.on('save-global-settings-sync', (event, globalSettings) => {
|
|
||||||
try {
|
|
||||||
const current = configStore.load();
|
|
||||||
current.globalSettings = globalSettings;
|
|
||||||
fs.writeFileSync(configStore.filePath, JSON.stringify(current, null, 2));
|
|
||||||
} catch {}
|
|
||||||
event.returnValue = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Folder Monitor ---
|
// --- Folder Monitor ---
|
||||||
function startFolderMonitor(settings) {
|
function startFolderMonitor(settings) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-hoster-uploader",
|
"name": "multi-hoster-uploader",
|
||||||
"version": "2.2.3",
|
"version": "2.2.2",
|
||||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -14,7 +14,6 @@ contextBridge.exposeInMainWorld('api', {
|
|||||||
// Global settings
|
// Global settings
|
||||||
getGlobalSettings: () => ipcRenderer.invoke('get-global-settings'),
|
getGlobalSettings: () => ipcRenderer.invoke('get-global-settings'),
|
||||||
saveGlobalSettings: (settings) => ipcRenderer.invoke('save-global-settings', settings),
|
saveGlobalSettings: (settings) => ipcRenderer.invoke('save-global-settings', settings),
|
||||||
saveGlobalSettingsSync: (settings) => ipcRenderer.sendSync('save-global-settings-sync', settings),
|
|
||||||
|
|
||||||
// Always on top
|
// Always on top
|
||||||
setAlwaysOnTop: (value) => ipcRenderer.invoke('set-always-on-top', value),
|
setAlwaysOnTop: (value) => ipcRenderer.invoke('set-always-on-top', value),
|
||||||
|
|||||||
@ -1487,9 +1487,6 @@ function handleProgress(data) {
|
|||||||
indexJob(job);
|
indexJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't regress from terminal states (stale callbacks can arrive after completion)
|
|
||||||
if (job.status === 'done' || job.status === 'skipped') return;
|
|
||||||
|
|
||||||
// Update job state
|
// Update job state
|
||||||
job.status = data.status;
|
job.status = data.status;
|
||||||
job.bytesUploaded = data.bytesUploaded || 0;
|
job.bytesUploaded = data.bytesUploaded || 0;
|
||||||
@ -3044,16 +3041,14 @@ function sortHistoryRows(rows) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush pending queue state on window close (sync IPC — blocks until save completes)
|
// Flush pending queue state on window close
|
||||||
window.addEventListener('beforeunload', () => {
|
window.addEventListener('beforeunload', () => {
|
||||||
|
if (queuePersistTimer) {
|
||||||
clearTimeout(queuePersistTimer);
|
clearTimeout(queuePersistTimer);
|
||||||
queuePersistTimer = null;
|
queuePersistTimer = null;
|
||||||
const globalSettings = {
|
// Synchronous-ish: fire and forget since window is closing
|
||||||
...(config.globalSettings || {}),
|
persistQueueStateNow().catch(() => {});
|
||||||
pendingQueue: buildPersistedQueueState()
|
}
|
||||||
};
|
|
||||||
config.globalSettings = globalSettings;
|
|
||||||
window.api.saveGlobalSettingsSync(globalSettings);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- Setup Listeners ---
|
// --- Setup Listeners ---
|
||||||
@ -3257,7 +3252,6 @@ function showUpdateBanner(info) {
|
|||||||
document.getElementById('installUpdateBtn').onclick = async () => {
|
document.getElementById('installUpdateBtn').onclick = async () => {
|
||||||
msg.textContent = 'Update wird heruntergeladen...';
|
msg.textContent = 'Update wird heruntergeladen...';
|
||||||
document.getElementById('installUpdateBtn').disabled = true;
|
document.getElementById('installUpdateBtn').disabled = true;
|
||||||
await persistQueueStateNow().catch(() => {}); // Save queue before update restart
|
|
||||||
await window.api.installUpdate();
|
await window.api.installUpdate();
|
||||||
};
|
};
|
||||||
document.getElementById('dismissUpdateBtn').onclick = () => { banner.style.display = 'none'; };
|
document.getElementById('dismissUpdateBtn').onclick = () => { banner.style.display = 'none'; };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user