mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
desktop: prevent downloading multiple updates
This commit is contained in:
@@ -28,13 +28,17 @@ type UpdateInfo = { version: string };
|
|||||||
type Progress = { percent: number };
|
type Progress = { percent: number };
|
||||||
|
|
||||||
const t = initTRPC.create();
|
const t = initTRPC.create();
|
||||||
|
let cancellationToken: CancellationToken | undefined = undefined;
|
||||||
|
|
||||||
export const updaterRouter = t.router({
|
export const updaterRouter = t.router({
|
||||||
autoUpdates: t.procedure.query(() => config.automaticUpdates),
|
autoUpdates: t.procedure.query(() => config.automaticUpdates),
|
||||||
install: t.procedure.query(() => autoUpdater.quitAndInstall()),
|
install: t.procedure.query(() => autoUpdater.quitAndInstall()),
|
||||||
download: t.procedure.query(async () => {
|
download: t.procedure.query(async () => {
|
||||||
const cancellationToken = new CancellationToken();
|
if (cancellationToken) return;
|
||||||
await autoUpdater.downloadUpdate(cancellationToken);
|
cancellationToken = new CancellationToken();
|
||||||
|
await autoUpdater
|
||||||
|
.downloadUpdate(cancellationToken)
|
||||||
|
.finally(() => (cancellationToken = undefined));
|
||||||
}),
|
}),
|
||||||
check: t.procedure.query(async () => {
|
check: t.procedure.query(async () => {
|
||||||
await autoUpdater.checkForUpdates();
|
await autoUpdater.checkForUpdates();
|
||||||
|
|||||||
Reference in New Issue
Block a user