Fix updater being corrupted by multiple attempts to download

This commit is contained in:
TrainDoctor
2022-08-23 15:23:23 -07:00
parent 8b3f569a09
commit de1c89af21
4 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
} }
}, },
"dependencies": { "dependencies": {
"decky-frontend-lib": "^1.7.5", "decky-frontend-lib": "^1.7.8",
"react-icons": "^4.4.0" "react-icons": "^4.4.0"
} }
} }
+8 -4
View File
@@ -9,7 +9,7 @@ specifiers:
'@types/react': 16.14.0 '@types/react': 16.14.0
'@types/react-router': 5.1.18 '@types/react-router': 5.1.18
'@types/webpack': ^5.28.0 '@types/webpack': ^5.28.0
decky-frontend-lib: ^1.7.5 decky-frontend-lib: ^1.7.8
husky: ^8.0.1 husky: ^8.0.1
import-sort-style-module: ^6.0.0 import-sort-style-module: ^6.0.0
inquirer: ^8.2.4 inquirer: ^8.2.4
@@ -23,7 +23,7 @@ specifiers:
typescript: ^4.7.4 typescript: ^4.7.4
dependencies: dependencies:
decky-frontend-lib: 1.7.5 decky-frontend-lib: 1.7.8
react-icons: 4.4.0_react@16.14.0 react-icons: 4.4.0_react@16.14.0
devDependencies: devDependencies:
@@ -806,8 +806,8 @@ packages:
ms: 2.1.2 ms: 2.1.2
dev: true dev: true
/decky-frontend-lib/1.7.5: /decky-frontend-lib/1.7.8:
resolution: {integrity: sha512-1OX/Ix9W76gF0NJjfm0k/01LYPmC2k/k+k/qqH8JJPlPHh5+W5P8ZG2T8m5wKsqoP7jx2W3k7RNZBh9vAqFoFw==} resolution: {integrity: sha512-CO6EJDxw/Eb6Ovng29IhZxC7SrlGT/iWMgFtKp7x3e7SVfwk9VHygyYBeVHaicj4n4LMgNE8iehh5k22Keyvbw==}
dependencies: dependencies:
minimist: 1.2.6 minimist: 1.2.6
dev: false dev: false
@@ -1255,6 +1255,10 @@ packages:
brace-expansion: 1.1.11 brace-expansion: 1.1.11
dev: true dev: true
/minimist/1.2.6:
resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==}
dev: false
/ms/2.1.2: /ms/2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: true dev: true
+8
View File
@@ -8,6 +8,7 @@ interface PublicDeckyState {
activePlugin: Plugin | null; activePlugin: Plugin | null;
updates: PluginUpdateMapping | null; updates: PluginUpdateMapping | null;
hasLoaderUpdate?: boolean; hasLoaderUpdate?: boolean;
isLoaderUpdating: boolean;
} }
export class DeckyState { export class DeckyState {
@@ -15,6 +16,7 @@ export class DeckyState {
private _activePlugin: Plugin | null = null; private _activePlugin: Plugin | null = null;
private _updates: PluginUpdateMapping | null = null; private _updates: PluginUpdateMapping | null = null;
private _hasLoaderUpdate: boolean = false; private _hasLoaderUpdate: boolean = false;
private _isLoaderUpdating: boolean = false;
public eventBus = new EventTarget(); public eventBus = new EventTarget();
@@ -24,6 +26,7 @@ export class DeckyState {
activePlugin: this._activePlugin, activePlugin: this._activePlugin,
updates: this._updates, updates: this._updates,
hasLoaderUpdate: this._hasLoaderUpdate, hasLoaderUpdate: this._hasLoaderUpdate,
isLoaderUpdating: this._isLoaderUpdating,
}; };
} }
@@ -52,6 +55,11 @@ export class DeckyState {
this.notifyUpdate(); this.notifyUpdate();
} }
setIsLoaderUpdating(isUpdating: boolean) {
this._isLoaderUpdating = isUpdating;
this.notifyUpdate();
}
private notifyUpdate() { private notifyUpdate() {
this.eventBus.dispatchEvent(new Event('update')); this.eventBus.dispatchEvent(new Event('update'));
} }
@@ -9,6 +9,8 @@ export default function UpdaterSettings() {
const [updateProgress, setUpdateProgress] = useState<number>(-1); const [updateProgress, setUpdateProgress] = useState<number>(-1);
const [reloading, setReloading] = useState<boolean>(false); const [reloading, setReloading] = useState<boolean>(false);
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false); const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
const [loaderUpdating, setLoaderUpdating] = useState<boolean>(false);
useEffect(() => { useEffect(() => {
(async () => { (async () => {
const res = (await callUpdaterMethod('get_version')) as { result: VerInfo }; const res = (await callUpdaterMethod('get_version')) as { result: VerInfo };
@@ -36,7 +38,7 @@ export default function UpdaterSettings() {
> >
{updateProgress == -1 ? ( {updateProgress == -1 ? (
<DialogButton <DialogButton
disabled={!versionInfo?.updatable || checkingForUpdates} disabled={!versionInfo?.updatable || checkingForUpdates || loaderUpdating}
onClick={ onClick={
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current !versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? async () => { ? async () => {
@@ -49,10 +51,12 @@ export default function UpdaterSettings() {
window.DeckyUpdater = { window.DeckyUpdater = {
updateProgress: (i) => { updateProgress: (i) => {
setUpdateProgress(i); setUpdateProgress(i);
setLoaderUpdating(true);
}, },
finish: async () => { finish: async () => {
setUpdateProgress(0); setUpdateProgress(0);
setReloading(true); setReloading(true);
setLoaderUpdating(false);
await finishUpdate(); await finishUpdate();
}, },
}; };