1
1
import * as path from "path" ;
2
- import * as temp from "temp" ;
3
2
import { cache } from "../../decorators" ;
4
3
import { executeActionByChunks } from "../../helpers" ;
5
4
import { DEFAULT_CHUNK_SIZE , LiveSyncPaths } from "../../constants" ;
@@ -10,7 +9,8 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
10
9
constructor ( private adb : Mobile . IDeviceAndroidDebugBridge ,
11
10
private appIdentifier : string ,
12
11
private $fs : IFileSystem ,
13
- private $mobileHelper : Mobile . IMobileHelper ) {
12
+ private $mobileHelper : Mobile . IMobileHelper ,
13
+ private $tempService : ITempService ) {
14
14
}
15
15
16
16
@cache ( )
@@ -34,8 +34,9 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
34
34
}
35
35
36
36
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 ) ;
39
40
}
40
41
41
42
public async updateHashes ( localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > {
@@ -86,20 +87,20 @@ export class AndroidDeviceHashService implements Mobile.IAndroidDeviceHashServic
86
87
}
87
88
88
89
@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 ) ;
91
92
}
92
93
93
94
@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 } ` ) ;
97
97
}
98
98
99
99
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 ( ) ] ) ;
102
103
}
103
- return this . hashFileLocalPath ;
104
+ return hashFileLocalPath ;
104
105
}
105
106
}
0 commit comments