@@ -227,10 +227,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
227227
228228def save_status (base_path , pair , collection = None , data_type = None , data = None ):
229229 assert data_type is not None
230- assert data is not None
231230 status_name = get_status_name (pair , collection )
232231 path = expand_path (os .path .join (base_path , status_name )) + "." + data_type
233232 prepare_status_path (path )
233+ if data is None :
234+ try :
235+ os .remove (path )
236+ except OSError : # the file has not existed
237+ pass
238+ return
234239
235240 with atomic_write (path , mode = "w" , overwrite = True ) as f :
236241 json .dump (data , f )
@@ -330,6 +335,19 @@ def assert_permissions(path, wanted):
330335 os .chmod (path , wanted )
331336
332337
338+ def handle_collection_was_removed (config , collection ):
339+ if "delete" in config ["implicit" ]:
340+ storage_type = config ["type" ]
341+ cls , config = storage_class_from_config (config )
342+ config ["collection" ] = collection
343+ try :
344+ args = cls .delete_collection (** config )
345+ args ["type" ] = storage_type
346+ return args
347+ except NotImplementedError as e :
348+ cli_logger .error (e )
349+
350+
333351async def handle_collection_not_found (config , collection , e = None ):
334352 storage_name = config .get ("instance_name" , None )
335353
@@ -339,7 +357,8 @@ async def handle_collection_not_found(config, collection, e=None):
339357 )
340358 )
341359
342- if click .confirm ("Should vdirsyncer attempt to create it?" ):
360+ if "create" in config ["implicit" ] or click .confirm (
361+ "Should vdirsyncer attempt to create it?" ):
343362 storage_type = config ["type" ]
344363 cls , config = storage_class_from_config (config )
345364 config ["collection" ] = collection
0 commit comments