@@ -232,10 +232,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
232232
233233def save_status (base_path , pair , collection = None , data_type = None , data = None ):
234234 assert data_type is not None
235- assert data is not None
236235 status_name = get_status_name (pair , collection )
237236 path = expand_path (os .path .join (base_path , status_name )) + "." + data_type
238237 prepare_status_path (path )
238+ if data is None :
239+ try :
240+ os .remove (path )
241+ except OSError : # the file has not existed
242+ pass
243+ return
239244
240245 with atomic_write (path , mode = "w" , overwrite = True ) as f :
241246 json .dump (data , f )
@@ -335,6 +340,19 @@ def assert_permissions(path, wanted):
335340 os .chmod (path , wanted )
336341
337342
343+ def handle_collection_was_removed (config , collection ):
344+ if "delete" in config ["implicit" ]:
345+ storage_type = config ["type" ]
346+ cls , config = storage_class_from_config (config )
347+ config ["collection" ] = collection
348+ try :
349+ args = cls .delete_collection (** config )
350+ args ["type" ] = storage_type
351+ return args
352+ except NotImplementedError as e :
353+ cli_logger .error (e )
354+
355+
338356async def handle_collection_not_found (config , collection , e = None ):
339357 storage_name = config .get ("instance_name" , None )
340358
@@ -344,7 +362,8 @@ async def handle_collection_not_found(config, collection, e=None):
344362 )
345363 )
346364
347- if click .confirm ("Should vdirsyncer attempt to create it?" ):
365+ if "create" in config ["implicit" ] or click .confirm (
366+ "Should vdirsyncer attempt to create it?" ):
348367 storage_type = config ["type" ]
349368 cls , config = storage_class_from_config (config )
350369 config ["collection" ] = collection
0 commit comments