Fix blocking upload logging and recover DoodStream socket failures; release 2.1.67
CI / verify (push) Canceled after 0s
CI / verify (push) Canceled after 0s
This commit is contained in:
1 parent
5a0cad0ca5
commit
9b06b4f852
10 files changed
+254
-114
No files matched your search
+23
-1
@@ -143,6 +143,28 @@ function createNativeStartupLog({ fs, path, directory, commandLine, now = Date.n
|
||||
} catch { return false; }
|
||||
finally { if (descriptor !== undefined) { try { fs.closeSync(descriptor); } catch {} } }
|
||||
};
|
||||
let maintenance = null;
|
||||
const maintainAsync = () => {
|
||||
if (maintenance) return maintenance;
|
||||
maintenance = (async () => {
|
||||
if (!enabled) return false;
|
||||
let handle;
|
||||
try {
|
||||
const size = (await fs.promises.stat(nativePath)).size;
|
||||
if (size <= maxBytes) return true;
|
||||
handle = await fs.promises.open(nativePath, 'r');
|
||||
const buffer = Buffer.alloc(maxBytes);
|
||||
const { bytesRead } = await handle.read(buffer, 0, buffer.length, size - buffer.length);
|
||||
await handle.close();
|
||||
handle = null;
|
||||
await fs.promises.writeFile(nativePath + '.previous', buffer.subarray(0, bytesRead), { mode: 0o600 });
|
||||
await fs.promises.truncate(nativePath, 0);
|
||||
return true;
|
||||
} catch { return false; }
|
||||
finally { if (handle) await handle.close().catch(() => {}); }
|
||||
})().finally(() => { maintenance = null; });
|
||||
return maintenance;
|
||||
};
|
||||
const files = () => list(nativePattern).sort((a, b) => Number(b.path === nativePath) - Number(a.path === nativePath))
|
||||
.map(file => ({ label: file.name, path: file.path, maxBytes }));
|
||||
const reports = () => list(reportPattern).sort((a, b) => Number(b.path === latestReport) - Number(a.path === latestReport))
|
||||
@@ -159,7 +181,7 @@ function createNativeStartupLog({ fs, path, directory, commandLine, now = Date.n
|
||||
} catch { return null; }
|
||||
};
|
||||
prune(reportPattern, 10);
|
||||
return { enabled, nativePath, logDirectory, files, reports, saveReport, maintain };
|
||||
return { enabled, nativePath, logDirectory, files, reports, saveReport, maintain, maintainAsync };
|
||||
}
|
||||
|
||||
module.exports = { createStartupWindow, resolveStartupLanguage, createStartupQuery, createStartupDiagnostics, summarizeStartupPixels, createNativeStartupLog };
|
||||
Reference in new issue
Block a user