@@ -3,18 +3,29 @@ import * as util from "util";
3
3
import { APP_FOLDER_NAME } from "../../constants" ;
4
4
5
5
export abstract class PlatformLiveSyncServiceBase {
6
+ private _deviceLiveSyncServicesCache : IDictionary < INativeScriptDeviceLiveSyncService > = { } ;
7
+
6
8
constructor ( protected $fs : IFileSystem ,
7
9
protected $logger : ILogger ,
8
10
protected $platformsData : IPlatformsData ,
9
11
protected $projectFilesManager : IProjectFilesManager ,
10
12
private $devicePathProvider : IDevicePathProvider ,
11
13
private $projectFilesProvider : IProjectFilesProvider ) { }
12
14
13
- public abstract getDeviceLiveSyncService ( device : Mobile . IDevice ) : INativeScriptDeviceLiveSyncService ;
15
+ public getDeviceLiveSyncService ( device : Mobile . IDevice , applicationIdentifier : string ) : INativeScriptDeviceLiveSyncService {
16
+ const key = device . deviceInfo . identifier + applicationIdentifier ;
17
+ if ( ! this . _deviceLiveSyncServicesCache [ key ] ) {
18
+ this . _deviceLiveSyncServicesCache [ key ] = this . _getDeviceLiveSyncService ( device ) ;
19
+ }
20
+
21
+ return this . _deviceLiveSyncServicesCache [ key ] ;
22
+ }
23
+
24
+ protected abstract _getDeviceLiveSyncService ( device : Mobile . IDevice ) : INativeScriptDeviceLiveSyncService ;
14
25
15
26
public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) : Promise < void > {
16
27
if ( liveSyncInfo . isFullSync || liveSyncInfo . modifiedFilesData . length ) {
17
- const deviceLiveSyncService = this . getDeviceLiveSyncService ( liveSyncInfo . deviceAppData . device ) ;
28
+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( liveSyncInfo . deviceAppData . device , projectData . projectId ) ;
18
29
this . $logger . info ( "Refreshing application..." ) ;
19
30
await deviceLiveSyncService . refreshApplication ( projectData , liveSyncInfo ) ;
20
31
}
@@ -23,7 +34,7 @@ export abstract class PlatformLiveSyncServiceBase {
23
34
public async fullSync ( syncInfo : IFullSyncInfo ) : Promise < ILiveSyncResultInfo > {
24
35
const projectData = syncInfo . projectData ;
25
36
const device = syncInfo . device ;
26
- const deviceLiveSyncService = this . getDeviceLiveSyncService ( device ) ;
37
+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( device , syncInfo . projectData . projectId ) ;
27
38
const platformData = this . $platformsData . getPlatformData ( device . deviceInfo . platform , projectData ) ;
28
39
const deviceAppData = await this . getAppData ( syncInfo ) ;
29
40
@@ -79,7 +90,7 @@ export abstract class PlatformLiveSyncServiceBase {
79
90
const localToDevicePaths = await this . $projectFilesManager . createLocalToDevicePaths ( deviceAppData , projectFilesPath , mappedFiles , [ ] ) ;
80
91
modifiedLocalToDevicePaths . push ( ...localToDevicePaths ) ;
81
92
82
- const deviceLiveSyncService = this . getDeviceLiveSyncService ( device ) ;
93
+ const deviceLiveSyncService = this . getDeviceLiveSyncService ( device , projectData . projectId ) ;
83
94
deviceLiveSyncService . removeFiles ( deviceAppData , localToDevicePaths ) ;
84
95
}
85
96
0 commit comments