11import * as path from "path" ;
2- import * as temp from "temp" ;
32import { cache } from "../../decorators" ;
43import { executeActionByChunks } from "../../helpers" ;
54import { DEFAULT_CHUNK_SIZE , LiveSyncPaths } from "../../constants" ;
@@ -10,7 +9,8 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
109 constructor ( private adb : Mobile . IDeviceAndroidDebugBridge ,
1110 private appIdentifier : string ,
1211 private $fs : IFileSystem ,
13- private $mobileHelper : Mobile . IMobileHelper ) {
12+ private $mobileHelper : Mobile . IMobileHelper ,
13+ private $tempService : ITempService ) {
1414 }
1515
1616 @cache ( )
@@ -34,8 +34,9 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
3434 }
3535
3636 public async uploadHashFileToDevice ( data : IStringDictionary ) : Promise < void > {
37- this . $fs . writeJson ( this . hashFileLocalPath , data ) ;
38- await this . adb . pushFile ( this . hashFileLocalPath , this . hashFileDevicePath ) ;
37+ const hashFileLocalPath = await this . getHashFileLocalPath ( ) ;
38+ this . $fs . writeJson ( hashFileLocalPath , data ) ;
39+ await this . adb . pushFile ( hashFileLocalPath , this . hashFileDevicePath ) ;
3940 }
4041
4142 public async updateHashes ( localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
@@ -86,20 +87,20 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
8687 }
8788
8889 @cache ( )
89- private get hashFileLocalPath ( ) : string {
90- return path . join ( this . tempDir , AndroidDeviceHashService . HASH_FILE_NAME ) ;
90+ private async getHashFileLocalPath ( ) : Promise < string > {
91+ return path . join ( await this . getTempDir ( ) , AndroidDeviceHashService . HASH_FILE_NAME ) ;
9192 }
9293
9394 @cache ( )
94- private get tempDir ( ) : string {
95- temp . track ( ) ;
96- return temp . mkdirSync ( `android-device-hash-service-${ this . appIdentifier } ` ) ;
95+ private getTempDir ( ) : Promise < string > {
96+ return this . $tempService . mkdirSync ( `android-device-hash-service-${ this . appIdentifier } ` ) ;
9797 }
9898
9999 private async downloadHashFileFromDevice ( ) : Promise < string > {
100- if ( ! this . $fs . exists ( this . hashFileLocalPath ) ) {
101- await this . adb . executeCommand ( [ "pull" , this . hashFileDevicePath , this . tempDir ] ) ;
100+ const hashFileLocalPath = await this . getHashFileLocalPath ( ) ;
101+ if ( ! this . $fs . exists ( hashFileLocalPath ) ) {
102+ await this . adb . executeCommand ( [ "pull" , this . hashFileDevicePath , await this . getTempDir ( ) ] ) ;
102103 }
103- return this . hashFileLocalPath ;
104+ return hashFileLocalPath ;
104105 }
105106}
0 commit comments