This commit is contained in:
1 parent
c4439480bd
commit
267a840853
4 files changed
+34
-18
No files matched your search
@@ -185,7 +185,11 @@ const mcpUpdate = new McpUpdate({
|
||||
handoff: async prepared => {
|
||||
if (!closeHandshakeReady || updatePreparationPromise || preparedUpdate) throw new McpAccessError('UPDATE_BUSY');
|
||||
await new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => { rejectPendingUpdate(new Error('Update close timeout')); }, 15000);
|
||||
const timer = setTimeout(() => {
|
||||
if (closeLaunchAttempt !== null) return;
|
||||
restoreClosePreparation(closePreparationAttempt);
|
||||
rejectPendingUpdate(new Error('Update close timeout'));
|
||||
}, MCP_UPDATE_CLOSE_TIMEOUT_MS);
|
||||
mcpUpdateHandoff = { resolve: () => { clearTimeout(timer); resolve(); }, reject: error => { clearTimeout(timer); reject(error); } };
|
||||
preparedUpdate = prepared;
|
||||
updateQuitPending = true;
|
||||
@@ -329,6 +333,12 @@ function clearCloseFlushTimer() {
|
||||
closeFlushTimer = null;
|
||||
}
|
||||
|
||||
const CLOSE_STORAGE_TIMEOUT_MS = 120000;
|
||||
const CLOSE_RENDERER_ACK_TIMEOUT_MS = 5000;
|
||||
const CLOSE_RENDERER_FLUSH_TIMEOUT_MS = 245000;
|
||||
const MCP_UPDATE_CLOSE_TIMEOUT_MS = 900000;
|
||||
let closeLaunchAttempt = null;
|
||||
|
||||
function waitForCloseOperation(promise, timeoutMs) {
|
||||
return Promise.race([
|
||||
Promise.resolve(promise),
|
||||
@@ -387,6 +397,7 @@ function rejectPendingUpdate(error) {
|
||||
}
|
||||
|
||||
function restoreClosePreparation(attempt, clearRestart = true) {
|
||||
if (closeLaunchAttempt === attempt) return false;
|
||||
if (!isClosePreparationActive(attempt)) return lastRestoredCloseAttempt === attempt;
|
||||
closeFlushApproved = false;
|
||||
closeFlushRequested = false;
|
||||
@@ -423,10 +434,10 @@ function requestClosePreparation() {
|
||||
try { if (uploadManager) uploadManager.cancel(); } catch {}
|
||||
(async () => {
|
||||
try {
|
||||
await waitForCloseOperation(Promise.all(Array.from(activeUploadProducerTrackers, tracker => tracker.promise)), 2500);
|
||||
await waitForCloseOperation(Promise.all(Array.from(activeUploadProducerTrackers, tracker => tracker.promise)), CLOSE_STORAGE_TIMEOUT_MS);
|
||||
if (attempt !== closePreparationAttempt || !closeFlushRequested) return;
|
||||
safeSend('app:prepare-close', attempt);
|
||||
armCloseFlushTimer(attempt, 1500);
|
||||
armCloseFlushTimer(attempt, CLOSE_RENDERER_ACK_TIMEOUT_MS);
|
||||
} catch {
|
||||
restoreClosePreparation(attempt);
|
||||
}
|
||||
@@ -3653,7 +3664,7 @@ ipcMain.on('folder-monitor:renderer-ready', (event, generation) => {
|
||||
|
||||
ipcMain.on('app:close-preparation-started', (event, attempt) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed() && event.sender === mainWindow.webContents && isClosePreparationActive(attempt)) {
|
||||
armCloseFlushTimer(attempt, 3000);
|
||||
armCloseFlushTimer(attempt, CLOSE_RENDERER_FLUSH_TIMEOUT_MS);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3674,19 +3685,21 @@ ipcMain.handle('app:finish-close', async (event, payload = true) => {
|
||||
let approved = false;
|
||||
try {
|
||||
if (!acquireCloseQuiesce(attempt)) return false;
|
||||
await waitForCloseOperation(waitForConfigStoreWrites(), 1000);
|
||||
await waitForCloseOperation(drainRuntimeLogs(), 5000);
|
||||
await waitForCloseOperation(waitForConfigStoreWrites(), CLOSE_STORAGE_TIMEOUT_MS);
|
||||
await waitForCloseOperation(drainRuntimeLogs(), CLOSE_STORAGE_TIMEOUT_MS);
|
||||
if (!isClosePreparationActive(attempt)) return false;
|
||||
if (payload && typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'pendingQueue')) {
|
||||
await waitForCloseOperation(configStore.savePendingQueue(payload.pendingQueue, { allowDuringQuiesce: true }), 1000);
|
||||
await waitForCloseOperation(configStore.savePendingQueue(payload.pendingQueue, { allowDuringQuiesce: true }), CLOSE_STORAGE_TIMEOUT_MS);
|
||||
}
|
||||
if (!isClosePreparationActive(attempt)) return false;
|
||||
if (mcpUpdateHandoff) {
|
||||
closeLaunchAttempt = attempt;
|
||||
await mcpUpdate.markLaunching();
|
||||
await launchVerifiedUpdate(preparedUpdate, path.dirname(process.execPath));
|
||||
preparedUpdateLaunchStarted = true;
|
||||
mcpUpdateHandoff.resolve();
|
||||
const handoff = mcpUpdateHandoff;
|
||||
mcpUpdateHandoff = null;
|
||||
handoff?.resolve();
|
||||
}
|
||||
closeFlushApproved = true;
|
||||
approved = true;
|
||||
@@ -3695,6 +3708,7 @@ ipcMain.handle('app:finish-close', async (event, payload = true) => {
|
||||
});
|
||||
return true;
|
||||
} catch {
|
||||
if (closeLaunchAttempt === attempt) closeLaunchAttempt = null;
|
||||
if (mcpUpdateHandoff) await mcpUpdate.launchFailed().catch(() => {});
|
||||
restoreClosePreparation(attempt);
|
||||
return false;
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "2.1.73",
|
||||
"version": "2.1.74",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "2.1.73",
|
||||
"version": "2.1.74",
|
||||
"dependencies": {
|
||||
"chokidar": "^4.0.3",
|
||||
"undici": "7.29.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "2.1.73",
|
||||
"version": "2.1.74",
|
||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+9
-7
@@ -9179,12 +9179,13 @@ let closePreparationInertState = [];
|
||||
let closePreparationOverlayState = null;
|
||||
let closePreparationGeneration = 0;
|
||||
let activeClosePreparationAttempt = null;
|
||||
const CLOSE_PREPARATION_TIMEOUT_MS = 1200;
|
||||
const CLOSE_PREPARATION_TIMEOUT_MS = 120000;
|
||||
const CLOSE_FINISH_TIMEOUT_MS = 420000;
|
||||
|
||||
function waitForClosePreparationStep(promise) {
|
||||
function waitForClosePreparationStep(promise, timeoutMs = CLOSE_PREPARATION_TIMEOUT_MS) {
|
||||
return Promise.race([
|
||||
Promise.resolve(promise),
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error('Speichern vor dem Beenden hat zu lange gedauert')), CLOSE_PREPARATION_TIMEOUT_MS))
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error('Speichern vor dem Beenden hat zu lange gedauert')), timeoutMs))
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -9238,6 +9239,7 @@ async function recoverWindowClose(generation, attempt, originalError) {
|
||||
showCopyToast('Die Anwendung konnte nach dem fehlgeschlagenen Speichern nicht entsperrt werden', 8000, 'error');
|
||||
return;
|
||||
}
|
||||
let recoveryError = null;
|
||||
try {
|
||||
await waitForClosePreparationStep(withCloseWriteAccess(async () => {
|
||||
await flushConfigWrites();
|
||||
@@ -9247,15 +9249,15 @@ async function recoverWindowClose(generation, attempt, originalError) {
|
||||
if (failedConfigWriteOperations.length !== 0) throw new Error('Nicht alle Einstellungen konnten gespeichert werden');
|
||||
}));
|
||||
} catch (error) {
|
||||
if (isCurrentClosePreparation(generation, attempt)) showCopyToast(error.message || String(error), 8000, 'error');
|
||||
return;
|
||||
recoveryError = error;
|
||||
}
|
||||
if (!isCurrentClosePreparation(generation, attempt)) return;
|
||||
closePreparationPromise = null;
|
||||
activeClosePreparationAttempt = null;
|
||||
closePreparationState = 'open';
|
||||
setClosePreparationUi(false);
|
||||
showCopyToast(originalError.message || String(originalError), 8000, 'error');
|
||||
const shownError = recoveryError || originalError;
|
||||
showCopyToast(shownError.message || String(shownError), 8000, 'error');
|
||||
}
|
||||
|
||||
function prepareForWindowClose(attempt) {
|
||||
@@ -9273,7 +9275,7 @@ function prepareForWindowClose(attempt) {
|
||||
closePreparationState = 'sealed';
|
||||
await waitForClosePreparationStep(flushConfigWrites());
|
||||
if (!isCurrentClosePreparation(generation, attempt)) return;
|
||||
const accepted = await waitForClosePreparationStep(window.api.finishClosePreparation({ ready: true, attempt, pendingQueue }));
|
||||
const accepted = await waitForClosePreparationStep(window.api.finishClosePreparation({ ready: true, attempt, pendingQueue }), CLOSE_FINISH_TIMEOUT_MS);
|
||||
if (!accepted) throw new Error('Einstellungen konnten vor dem Beenden nicht gespeichert werden');
|
||||
})();
|
||||
closePreparationPromise.catch(error => recoverWindowClose(generation, attempt, error));
|
||||
|
||||
Reference in new issue
Block a user