@@ -231,10 +231,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
231231
232232def save_status (base_path , pair , collection = None , data_type = None , data = None ):
233233 assert data_type is not None
234- assert data is not None
235234 status_name = get_status_name (pair , collection )
236235 path = expand_path (os .path .join (base_path , status_name )) + '.' + data_type
237236 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
238243
239244 with atomic_write (path , mode = 'w' , overwrite = True ) as f :
240245 json .dump (data , f )
@@ -397,14 +402,27 @@ def assert_permissions(path, wanted):
397402 os .chmod (path , wanted )
398403
399404
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+
400418def handle_collection_not_found (config , collection , e = None ):
401419 storage_name = config .get ('instance_name' , None )
402420
403421 cli_logger .warning ('{}No collection {} found for storage {}.'
404422 .format (f'{ e } \n ' if e else '' ,
405423 json .dumps (collection ), storage_name ))
406424
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?' ):
408426 storage_type = config ['type' ]
409427 cls , config = storage_class_from_config (config )
410428 config ['collection' ] = collection
0 commit comments