提交 af18dd70 编写于 作者: B Benjamin Pasero

working copy - backup() is not optional anymore

上级 cf432e54
......@@ -114,10 +114,6 @@ export abstract class BackupTracker extends Disposable {
return; // skip if auto save is enabled with a short delay
}
if (typeof workingCopy.backup !== 'function') {
return; // skip if working copy does not support backups
}
// Clear any running backup operation
dispose(this.pendingBackups.get(workingCopy));
this.pendingBackups.delete(workingCopy);
......@@ -131,7 +127,7 @@ export abstract class BackupTracker extends Disposable {
this.pendingBackups.delete(workingCopy);
// Backup if dirty
if (workingCopy.isDirty() && typeof workingCopy.backup === 'function') {
if (workingCopy.isDirty()) {
this.logService.trace(`[backup tracker] running backup`, workingCopy.resource.toString());
const backup = await workingCopy.backup();
......
......@@ -161,12 +161,10 @@ export class NativeBackupTracker extends BackupTracker implements IWorkbenchCont
// Backup does not exist
else {
if (typeof workingCopy.backup === 'function') {
const backup = await workingCopy.backup();
await this.backupFileService.backup(workingCopy.resource, backup.content, contentVersion, backup.meta);
const backup = await workingCopy.backup();
await this.backupFileService.backup(workingCopy.resource, backup.content, contentVersion, backup.meta);
backups.push(workingCopy);
}
backups.push(workingCopy);
}
}));
}
......
......@@ -42,10 +42,20 @@ export interface IWorkingCopyBackup {
export interface IWorkingCopy {
/**
* The unique resource of the working copy. There can only be one
* working copy in the system with the same URI.
*/
readonly resource: URI;
/**
* Human readable name of the working copy.
*/
readonly name: string;
/**
* The capabilities of the working copy.
*/
readonly capabilities: WorkingCopyCapabilities;
......@@ -83,14 +93,21 @@ export interface IWorkingCopy {
*
* Providers of working copies should use `IBackupFileService.resolve(workingCopy.resource)`
* to retrieve the backup metadata associated when loading the working copy.
*
* Not providing this method from the working copy will disable any
* backups and hot-exit functionality for those working copies.
*/
backup?(): Promise<IWorkingCopyBackup>;
backup(): Promise<IWorkingCopyBackup>;
/**
* Asks the working copy to save. If the working copy was dirty, it is
* expected to be non-dirty after this operation has finished.
*
* @returns `true` if the operation was successful and `false` otherwise.
*/
save(options?: ISaveOptions): Promise<boolean>;
/**
* Asks the working copy to revert. If the working copy was dirty, it is
* expected to be non-dirty after this operation has finished.
*/
revert(options?: IRevertOptions): Promise<void>;
//#endregion
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册