@@ -32,9 +32,17 @@ export class BackupService implements IBackupService {
3232 @IWorkspaceContextService contextService ?: IWorkspaceContextService
3333 ) {
3434 // IWorkspaceContextService will not exist on the main process
35- if ( contextService ) {
36- this . workspaceResource = contextService . getWorkspace ( ) . resource ;
35+ if ( ! contextService ) {
36+ return ;
3737 }
38+
39+ // Hot exit is disabled for empty workspaces
40+ const workspace = contextService . getWorkspace ( ) ;
41+ if ( ! workspace ) {
42+ return ;
43+ }
44+
45+ this . workspaceResource = workspace . resource ;
3846 }
3947
4048 public getWorkspaceBackupPaths ( ) : string [ ] {
@@ -52,6 +60,10 @@ export class BackupService implements IBackupService {
5260 public pushWorkspaceBackupPaths ( workspaces : string [ ] ) : void {
5361 this . load ( ) ;
5462 workspaces . forEach ( workspace => {
63+ // Hot exit is disabled for empty workspaces
64+ if ( ! workspace ) {
65+ return ;
66+ }
5567 if ( ! this . fileContent . folderWorkspaces [ workspace ] ) {
5668 this . fileContent . folderWorkspaces [ workspace ] = [ ] ;
5769 }
@@ -74,6 +86,11 @@ export class BackupService implements IBackupService {
7486 }
7587
7688 public getWorkspaceUntitledFileBackups ( workspace : string ) : string [ ] {
89+ // Hot exit is disabled for empty workspaces
90+ if ( ! this . workspaceResource ) {
91+ return ;
92+ }
93+
7794 const workspaceHash = crypto . createHash ( 'md5' ) . update ( this . workspaceResource . fsPath ) . digest ( 'hex' ) ;
7895 const untitledDir = path . join ( this . environmentService . backupHome , workspaceHash , 'untitled' ) ;
7996 try {
@@ -87,6 +104,10 @@ export class BackupService implements IBackupService {
87104 }
88105
89106 public getBackupResource ( resource : Uri ) : Uri {
107+ // Hot exit is disabled for empty workspaces
108+ if ( ! this . workspaceResource ) {
109+ return ;
110+ }
90111
91112 const workspaceHash = crypto . createHash ( 'md5' ) . update ( this . workspaceResource . fsPath ) . digest ( 'hex' ) ;
92113 const backupName = crypto . createHash ( 'md5' ) . update ( resource . fsPath ) . digest ( 'hex' ) ;
@@ -96,6 +117,11 @@ export class BackupService implements IBackupService {
96117 }
97118
98119 public registerResourceForBackup ( resource : Uri ) : void {
120+ // Hot exit is disabled for empty workspaces
121+ if ( ! this . workspaceResource ) {
122+ return ;
123+ }
124+
99125 this . load ( ) ;
100126 if ( arrays . contains ( this . fileContent . folderWorkspaces [ this . workspaceResource . fsPath ] , resource . fsPath ) ) {
101127 return ;
@@ -105,6 +131,11 @@ export class BackupService implements IBackupService {
105131 }
106132
107133 public deregisterResourceForBackup ( resource : Uri ) : void {
134+ // Hot exit is disabled for empty workspaces
135+ if ( ! this . workspaceResource ) {
136+ return ;
137+ }
138+
108139 this . load ( ) ;
109140 this . fileContent . folderWorkspaces [ this . workspaceResource . fsPath ] = this . fileContent . folderWorkspaces [ this . workspaceResource . fsPath ] . filter ( value => value !== resource . fsPath ) ;
110141 this . save ( ) ;
0 commit comments