blob: d4c07c0f67ae196ced7724b387611a9200c5058e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { WorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackupService';
import { URI } from 'vs/base/common/uri';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
import { IFileService } from 'vs/platform/files/common/files';
import { ILogService } from 'vs/platform/log/common/log';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { NativeWorkingCopyBackupTracker } from 'vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker';
export class NativeWorkingCopyBackupService extends WorkingCopyBackupService {
constructor(
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IFileService fileService: IFileService,
@ILogService logService: ILogService,
@ILifecycleService private readonly lifecycleService: ILifecycleService
) {
super(environmentService.backupPath ? URI.file(environmentService.backupPath).with({ scheme: environmentService.userRoamingDataHome.scheme }) : undefined, fileService, logService);
this.registerListeners();
}
private registerListeners(): void {
// Lifecycle: ensure to prolong the shutdown for as long
// as pending backup operations have not finished yet.
// Otherwise, we risk writing partial backups to disk.
this.lifecycleService.onWillShutdown(event => event.join(this.joinBackups(), 'join.workingCopyBackups'));
}
}
// Register Service
registerSingleton(IWorkingCopyBackupService, NativeWorkingCopyBackupService);
// Register Backup Tracker
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NativeWorkingCopyBackupTracker, LifecyclePhase.Starting);
|