@@ -4,7 +4,7 @@ import * as stream from 'stream';
44import * as semver from 'semver' ;
55import fetch from 'node-fetch' ;
66
7- import { readDir , createTmp , renameFile , deleteFile } from '../../util' ;
7+ import { readDir , createTmp , moveFile , deleteFile } from '../../util' ;
88import { HtkConfig } from '../../config' ;
99import { reportError } from '../../error-tracking' ;
1010
@@ -85,7 +85,7 @@ async function updateLocalApk(
8585
8686 console . log ( `Local APK written to ${ tmpApk } ` ) ;
8787
88- await renameFile ( tmpApk , path . join ( config . configPath , `httptoolkit-${ version } .apk` ) ) ;
88+ await moveFile ( tmpApk , path . join ( config . configPath , `httptoolkit-${ version } .apk` ) ) ;
8989 console . log ( `Local APK moved to ${ path . join ( config . configPath , `httptoolkit-${ version } .apk` ) } ` ) ;
9090 await cleanupOldApks ( config ) ;
9191}
@@ -123,7 +123,7 @@ export async function streamLatestApk(config: HtkConfig): Promise<stream.Readabl
123123 } else {
124124 console . log ( 'Streaming remote APK directly' ) ;
125125 const apkStream = ( await fetch ( latestApkRelease . url ) ) . body ;
126- updateLocalApk ( latestApkRelease . version , apkStream , config ) ;
126+ updateLocalApk ( latestApkRelease . version , apkStream , config ) . catch ( reportError ) ;
127127 return apkStream as stream . Readable ;
128128 }
129129 }
@@ -138,7 +138,7 @@ export async function streamLatestApk(config: HtkConfig): Promise<stream.Readabl
138138 // Try to update it async, and use the local APK in the meantime.
139139 fetch ( latestApkRelease . url ) . then ( ( apkResponse ) => {
140140 const apkStream = apkResponse . body ;
141- updateLocalApk ( latestApkRelease . version , apkStream , config ) ;
141+ return updateLocalApk ( latestApkRelease . version , apkStream , config ) ;
142142 } ) . catch ( reportError ) ;
143143
144144 console . log ( 'Streaming local APK, and updating it async' ) ;
0 commit comments