@@ -27,12 +27,14 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer
27
27
}
28
28
29
29
public async transferFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
30
- const transferredFiles = await this . transferFilesCore ( deviceAppData , localToDevicePaths , projectFilesPath , options ) ;
31
- await this . updateHashes ( deviceAppData , localToDevicePaths , projectData , liveSyncDeviceInfo ) ;
30
+ const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
31
+ const currentHashes = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
32
+ const transferredFiles = await this . transferFilesCore ( deviceAppData , localToDevicePaths , projectFilesPath , currentHashes , options ) ;
33
+ await this . updateHashes ( deviceAppData , currentHashes , projectData , liveSyncDeviceInfo ) ;
32
34
return transferredFiles ;
33
35
}
34
36
35
- private async transferFilesCore ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
37
+ private async transferFilesCore ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string , currentHashes : IStringDictionary , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
36
38
if ( options . force && options . isFullSync ) {
37
39
const hashFileDevicePath = this . getDeviceHashService ( deviceAppData . appIdentifier ) . hashFileDevicePath ;
38
40
await this . device . fileSystem . deleteFile ( hashFileDevicePath , deviceAppData . appIdentifier ) ;
@@ -41,39 +43,37 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer
41
43
return localToDevicePaths ;
42
44
}
43
45
44
- const localToDevicePathsToTransfer = await this . getLocalToDevicePathsToTransfer ( deviceAppData , localToDevicePaths , options ) ;
46
+ const localToDevicePathsToTransfer = await this . getLocalToDevicePathsToTransfer ( deviceAppData , localToDevicePaths , currentHashes , options ) ;
45
47
this . $logger . trace ( "Files to transfer: " , localToDevicePathsToTransfer ) ;
46
48
await this . transferFilesOnDevice ( deviceAppData , localToDevicePathsToTransfer ) ;
47
49
return localToDevicePathsToTransfer ;
48
50
}
49
51
50
- private async getLocalToDevicePathsToTransfer ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
52
+ private async getLocalToDevicePathsToTransfer ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , currentHashes : IStringDictionary , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
51
53
if ( options . force || ! options . isFullSync ) {
52
54
return localToDevicePaths ;
53
55
}
54
56
55
- const changedLocalToDevicePaths = await this . getChangedLocalToDevicePaths ( deviceAppData . appIdentifier , localToDevicePaths ) ;
57
+ const changedLocalToDevicePaths = await this . getChangedLocalToDevicePaths ( deviceAppData . appIdentifier , localToDevicePaths , currentHashes ) ;
56
58
return changedLocalToDevicePaths ;
57
59
}
58
60
59
- private async getChangedLocalToDevicePaths ( appIdentifier : string , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
61
+ private async getChangedLocalToDevicePaths ( appIdentifier : string , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , currentHashes : IStringDictionary ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
60
62
const deviceHashService = this . getDeviceHashService ( appIdentifier ) ;
61
- const currentHashes = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
62
63
const oldHashes = ( await deviceHashService . getShasumsFromDevice ( ) ) || { } ;
63
64
const changedHashes = deviceHashService . getChangedShasums ( oldHashes , currentHashes ) ;
64
65
const changedFiles = _ . keys ( changedHashes ) ;
65
66
const changedLocalToDevicePaths = localToDevicePaths . filter ( localToDevicePathData => changedFiles . indexOf ( localToDevicePathData . getLocalPath ( ) ) >= 0 ) ;
66
67
return changedLocalToDevicePaths ;
67
68
}
68
69
69
- private async updateHashes ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < void > {
70
- const hashes = await this . updateHashesOnDevice ( deviceAppData , localToDevicePaths , projectData , liveSyncDeviceInfo ) ;
70
+ private async updateHashes ( deviceAppData : Mobile . IDeviceAppData , currentHashes : IStringDictionary , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < void > {
71
+ const hashes = await this . updateHashesOnDevice ( deviceAppData , currentHashes , projectData , liveSyncDeviceInfo ) ;
71
72
this . updateLocalHashes ( hashes , deviceAppData , projectData , liveSyncDeviceInfo ) ;
72
73
}
73
74
74
- private async updateHashesOnDevice ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < IStringDictionary > {
75
+ private async updateHashesOnDevice ( deviceAppData : Mobile . IDeviceAppData , currentHashes : IStringDictionary , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < IStringDictionary > {
75
76
const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
76
- const currentHashes = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
77
77
await deviceHashService . uploadHashFileToDevice ( currentHashes ) ;
78
78
return currentHashes ;
79
79
}
0 commit comments