@@ -18,7 +18,7 @@ import { AbstractFileSynchroniser, AbstractInitializer, IAcceptResult, IFileReso
18
18
import { Change , IRemoteUserData , IUserDataSyncBackupStoreService , IUserDataSyncConfiguration , IUserDataSynchroniser , IUserDataSyncLogService , IUserDataSyncEnablementService , IUserDataSyncStoreService , SyncResource , USER_DATA_SYNC_SCHEME } from 'vs/platform/userDataSync/common/userDataSync' ;
19
19
20
20
interface ITasksSyncContent {
21
- tasks : string ;
21
+ tasks ? : string ;
22
22
}
23
23
24
24
interface ITasksResourcePreview extends IFileResourcePreview {
@@ -28,7 +28,7 @@ interface ITasksResourcePreview extends IFileResourcePreview {
28
28
export function getTasksContentFromSyncContent ( syncContent : string , logService : ILogService ) : string | null {
29
29
try {
30
30
const parsed = < ITasksSyncContent > JSON . parse ( syncContent ) ;
31
- return parsed . tasks ;
31
+ return parsed . tasks ?? null ;
32
32
} catch ( e ) {
33
33
logService . error ( e ) ;
34
34
return null ;
@@ -76,7 +76,7 @@ export class TasksSynchroniser extends AbstractFileSynchroniser implements IUser
76
76
let hasRemoteChanged : boolean = false ;
77
77
let hasConflicts : boolean = false ;
78
78
79
- if ( remoteContent ) {
79
+ if ( remoteUserData . syncData ) {
80
80
const localContent = fileContent ? fileContent . value . toString ( ) : null ;
81
81
if ( ! lastSyncContent // First time sync
82
82
|| lastSyncContent !== localContent // Local has forwarded
@@ -196,13 +196,17 @@ export class TasksSynchroniser extends AbstractFileSynchroniser implements IUser
196
196
if ( fileContent ) {
197
197
await this . backupLocal ( JSON . stringify ( this . toTasksSyncContent ( fileContent . value . toString ( ) ) ) ) ;
198
198
}
199
- await this . updateLocalFileContent ( content || '{}' , fileContent , force ) ;
199
+ if ( content ) {
200
+ await this . updateLocalFileContent ( content , fileContent , force ) ;
201
+ } else {
202
+ await this . deleteLocalFile ( ) ;
203
+ }
200
204
this . logService . info ( `${ this . syncResourceLogLabel } : Updated local tasks` ) ;
201
205
}
202
206
203
207
if ( remoteChange !== Change . None ) {
204
208
this . logService . trace ( `${ this . syncResourceLogLabel } : Updating remote tasks...` ) ;
205
- const remoteContents = JSON . stringify ( this . toTasksSyncContent ( content || '{}' ) ) ;
209
+ const remoteContents = JSON . stringify ( this . toTasksSyncContent ( content ) ) ;
206
210
remoteUserData = await this . updateRemoteUserData ( remoteContents , force ? null : remoteUserData . ref ) ;
207
211
this . logService . info ( `${ this . syncResourceLogLabel } : Updated remote tasks` ) ;
208
212
}
@@ -235,8 +239,8 @@ export class TasksSynchroniser extends AbstractFileSynchroniser implements IUser
235
239
return null ;
236
240
}
237
241
238
- private toTasksSyncContent ( tasks : string ) : ITasksSyncContent {
239
- return { tasks } ;
242
+ private toTasksSyncContent ( tasks : string | null ) : ITasksSyncContent {
243
+ return tasks ? { tasks } : { } ;
240
244
}
241
245
242
246
}
0 commit comments