🐛 fix: scaleParallelUploads inverted, settings lost on close, IPC leak
- scaleParallelUploads used Math.max instead of Math.min, causing MORE concurrent uploads instead of limiting them to the global count - Settings debounce (350ms) was not flushed on app close — user changes made right before closing were lost - onRemoteClientCount IPC listener was re-registered on every renderSettings() call, causing listener accumulation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ae318d2c62
commit
a4a2eaa736
@ -75,7 +75,7 @@ class UploadManager extends EventEmitter {
|
|||||||
const settings = { ...DEFAULT_SETTINGS, ...(this.hosterSettings[hoster] || {}) };
|
const settings = { ...DEFAULT_SETTINGS, ...(this.hosterSettings[hoster] || {}) };
|
||||||
const globalLimit = this._getGlobalParallelLimit();
|
const globalLimit = this._getGlobalParallelLimit();
|
||||||
if (this.globalSettings.scaleParallelUploads && globalLimit > 0) {
|
if (this.globalSettings.scaleParallelUploads && globalLimit > 0) {
|
||||||
settings.parallelCount = Math.max(settings.parallelCount || 1, globalLimit);
|
settings.parallelCount = Math.min(settings.parallelCount || 1, globalLimit);
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,6 +130,18 @@ async function init() {
|
|||||||
addPathsToQueue(paths);
|
addPathsToQueue(paths);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remote client count updates (registered once, not per renderSettings call)
|
||||||
|
window.api.onRemoteClientCount(() => {
|
||||||
|
const el = document.getElementById('remoteConnectionStatus');
|
||||||
|
if (el && el.style.color === 'rgb(16, 185, 129)') {
|
||||||
|
window.api.remoteStatus().then(status => {
|
||||||
|
if (status.running) {
|
||||||
|
el.textContent = `Aktiv auf Port ${status.port} — ${status.clientCount} Client(s) verbunden`;
|
||||||
|
}
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
window.api.debugLog('init complete, all listeners registered');
|
window.api.debugLog('init complete, all listeners registered');
|
||||||
|
|
||||||
// Restore always-on-top state
|
// Restore always-on-top state
|
||||||
@ -2195,17 +2207,7 @@ function renderSettings() {
|
|||||||
}
|
}
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
|
|
||||||
// Live client count updates
|
// Live client count updates (listener registered once in init, not here)
|
||||||
window.api.onRemoteClientCount((count) => {
|
|
||||||
const el = document.getElementById('remoteConnectionStatus');
|
|
||||||
if (el && el.style.color === 'rgb(16, 185, 129)') {
|
|
||||||
window.api.remoteStatus().then(status => {
|
|
||||||
if (status.running) {
|
|
||||||
el.textContent = `Aktiv auf Port ${status.port} — ${status.clientCount} Client(s) verbunden`;
|
|
||||||
}
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Backup Panel ---
|
// --- Backup Panel ---
|
||||||
const backupPanel = document.createElement('div');
|
const backupPanel = document.createElement('div');
|
||||||
@ -3067,6 +3069,12 @@ function sortHistoryRows(rows) {
|
|||||||
|
|
||||||
// Flush pending queue state on window close (sync IPC — blocks until save completes)
|
// Flush pending queue state on window close (sync IPC — blocks until save completes)
|
||||||
window.addEventListener('beforeunload', () => {
|
window.addEventListener('beforeunload', () => {
|
||||||
|
// Flush pending settings save if user changed settings right before closing
|
||||||
|
if (settingsSaveTimer) {
|
||||||
|
clearTimeout(settingsSaveTimer);
|
||||||
|
settingsSaveTimer = null;
|
||||||
|
try { saveSettings(); } catch {}
|
||||||
|
}
|
||||||
clearTimeout(queuePersistTimer);
|
clearTimeout(queuePersistTimer);
|
||||||
queuePersistTimer = null;
|
queuePersistTimer = null;
|
||||||
const globalSettings = {
|
const globalSettings = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user