@@ -231,10 +231,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
231
231
232
232
def save_status (base_path , pair , collection = None , data_type = None , data = None ):
233
233
assert data_type is not None
234
- assert data is not None
235
234
status_name = get_status_name (pair , collection )
236
235
path = expand_path (os .path .join (base_path , status_name )) + '.' + data_type
237
236
prepare_status_path (path )
237
+ if data is None :
238
+ try :
239
+ os .remove (path )
240
+ except OSError : # the file has not existed
241
+ pass
242
+ return
238
243
239
244
with atomic_write (path , mode = 'w' , overwrite = True ) as f :
240
245
json .dump (data , f )
@@ -397,14 +402,27 @@ def assert_permissions(path, wanted):
397
402
os .chmod (path , wanted )
398
403
399
404
405
+ def handle_collection_was_removed (config , collection ):
406
+ if 'delete' in config ['implicit' ]:
407
+ storage_type = config ['type' ]
408
+ cls , config = storage_class_from_config (config )
409
+ config ['collection' ] = collection
410
+ try :
411
+ args = cls .delete_collection (** config )
412
+ args ['type' ] = storage_type
413
+ return args
414
+ except NotImplementedError as e :
415
+ cli_logger .error (e )
416
+
417
+
400
418
def handle_collection_not_found (config , collection , e = None ):
401
419
storage_name = config .get ('instance_name' , None )
402
420
403
421
cli_logger .warning ('{}No collection {} found for storage {}.'
404
422
.format (f'{ e } \n ' if e else '' ,
405
423
json .dumps (collection ), storage_name ))
406
424
407
- if click .confirm ('Should vdirsyncer attempt to create it?' ):
425
+ if 'create' in config [ 'implicit' ] or click .confirm ('Should vdirsyncer attempt to create it?' ):
408
426
storage_type = config ['type' ]
409
427
cls , config = storage_class_from_config (config )
410
428
config ['collection' ] = collection
0 commit comments