Skip to content

Commit 3b34f67

Browse files
authored
Merge pull request #2941 from input-output-hk/fix/ddw-1061-download-file-remains-after-update
[DDW-1061] Downloaded installer being left behind after wallet is updated to latest version
2 parents 3692298 + 147a758 commit 3b34f67

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
### Fixes
66

7+
- Fixed downloaded installer being left in Downloads after latest update installs ([PR 2941](https://github.com/input-output-hk/daedalus/pull/2941))
78
- Fixed incorrect amount of token sent ([PR 2962](https://github.com/input-output-hk/daedalus/pull/2962))
89

910
### Chores
1011

1112
- Added Vasil-supported cardano-wallet ([PR 3001](https://github.com/input-output-hk/daedalus/pull/3001))
13+
- Upgraded webpack to version 5 ([PR 2772](https://github.com/input-output-hk/daedalus/pull/2772))
1214

1315
## 4.11.0
1416

@@ -25,7 +27,6 @@
2527

2628
### Chores
2729

28-
- Upgraded webpack to version 5 ([PR 2772](https://github.com/input-output-hk/daedalus/pull/2772))
2930
- Bumped vulnerable dependencies versions ([PR 2943](https://github.com/input-output-hk/daedalus/pull/2943))
3031
- Added support for Trezor firmware 2.5.1 ([PR 2991](https://github.com/input-output-hk/daedalus/pull/2991))
3132
- Added steps on how to link with `react-polymorph` and other external UI libraries ([PR 2948](https://github.com/input-output-hk/daedalus/pull/2948))

source/renderer/app/stores/AppUpdateStore.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,21 @@ export default class AppUpdateStore extends Store {
102102
}
103103

104104
// ================= REACTIONS ==================
105-
_watchForNewsfeedUpdates = () => {
105+
_watchForNewsfeedUpdates = async () => {
106106
const { update } = this.stores.newsFeed.newsFeedData;
107-
if (update) this._checkNewAppUpdate(update);
107+
if (update) {
108+
this._checkNewAppUpdate(update);
109+
} else {
110+
const isFileInDownloads = await this._checkFileExists();
111+
if (isFileInDownloads && !this.availableUpdate) {
112+
this._clearDownloads();
113+
}
114+
}
115+
};
116+
117+
_clearDownloads = async () => {
118+
this._removeUpdateFile();
119+
await this._removeLocalDataInfo();
108120
};
109121

110122
// ==================== PUBLIC ==================
@@ -186,7 +198,9 @@ export default class AppUpdateStore extends Store {
186198
* We can't simply compare with the `package.json` version
187199
* otherwise we would trigger the local data cleaning on every app load
188200
*/
189-
if (appUpdateCompleted === version) return false;
201+
if (appUpdateCompleted === version) {
202+
return false;
203+
}
190204

191205
// Was the update already installed?
192206
if (this.isUpdateInstalled(update)) {
@@ -263,26 +277,31 @@ export default class AppUpdateStore extends Store {
263277
await this._removeLocalDataInfo();
264278
return this._requestUpdateDownload(update);
265279
};
280+
266281
_removeLocalDataInfo = async () => {
267282
clearDownloadLocalDataChannel.request({
268283
id: APP_UPDATE_DOWNLOAD_ID,
269284
});
270285
};
286+
271287
_removeUpdateFile = () => {
272288
deleteDownloadedFile.request({
273289
id: APP_UPDATE_DOWNLOAD_ID,
274290
});
275291
};
292+
276293
_getUpdateDownloadLocalData = async (): Promise<
277294
DownloadLocalDataMainResponse
278295
> =>
279296
getDownloadLocalDataChannel.request({
280297
id: APP_UPDATE_DOWNLOAD_ID,
281298
});
299+
282300
_checkFileExists = async (): Promise<CheckFileExistsMainResponse> =>
283301
checkFileExistsChannel.request({
284302
id: APP_UPDATE_DOWNLOAD_ID,
285303
});
304+
286305
_manageUpdateResponse = ({
287306
eventType,
288307
info,
@@ -331,6 +350,7 @@ export default class AppUpdateStore extends Store {
331350
fileUrl: '',
332351
});
333352
};
353+
334354
_requestResumeUpdateDownload = async () => {
335355
await requestResumeDownloadChannel.request({
336356
id: APP_UPDATE_DOWNLOAD_ID,
@@ -341,6 +361,7 @@ export default class AppUpdateStore extends Store {
341361
},
342362
});
343363
};
364+
344365
// @ts-ignore ts-migrate(2749) FIXME: 'News' refers to a value, but is being used as a t... Remove this comment to see the full error message
345366
_requestUpdateDownload = (update: News) => {
346367
const { url: fileUrl } = this.getUpdateInfo(update);
@@ -354,6 +375,7 @@ export default class AppUpdateStore extends Store {
354375
},
355376
});
356377
};
378+
357379
_installUpdate = async () => {
358380
if (
359381
!this.availableUpdate ||
@@ -386,6 +408,7 @@ export default class AppUpdateStore extends Store {
386408
hash,
387409
});
388410
};
411+
389412
_manageQuitAndInstallResponse = ({
390413
status,
391414
data,
@@ -414,22 +437,26 @@ export default class AppUpdateStore extends Store {
414437
hash: '',
415438
});
416439
};
440+
417441
_setAppAutomaticUpdateFailed = async () => {
418442
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
419443
await this.setAppAutomaticUpdateFailedRequest.execute();
420444
runInAction(() => {
421445
this.isAutomaticUpdateFailed = true;
422446
});
423447
};
448+
424449
@action
425450
_openAppUpdateOverlay = () => {
426451
this.isUpdateProgressOpen = true;
427452
this.isUpdatePostponed = false;
428453
};
454+
429455
@action
430456
_closeAppUpdateOverlay = () => {
431457
this.isUpdateProgressOpen = false;
432458
};
459+
433460
@action
434461
_postponeUpdate = () => {
435462
this.isUpdatePostponed = true;

0 commit comments

Comments
 (0)