@@ -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