@@ -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 )
@@ -334,6 +339,19 @@ def assert_permissions(path, wanted):
334339 os .chmod (path , wanted )
335340
336341
342+ def handle_collection_was_removed (config , collection ):
343+ if "delete" in config ["implicit" ]:
344+ storage_type = config ["type" ]
345+ cls , config = storage_class_from_config (config )
346+ config ["collection" ] = collection
347+ try :
348+ args = cls .delete_collection (** config )
349+ args ["type" ] = storage_type
350+ return args
351+ except NotImplementedError as e :
352+ cli_logger .error (e )
353+
354+
337355async def handle_collection_not_found (config , collection , e = None ):
338356 storage_name = config .get ("instance_name" , None )
339357
@@ -343,7 +361,8 @@ async def handle_collection_not_found(config, collection, e=None):
343361 )
344362 )
345363
346- if click .confirm ("Should vdirsyncer attempt to create it?" ):
364+ if "create" in config ["implicit" ] or click .confirm (
365+ "Should vdirsyncer attempt to create it?" ):
347366 storage_type = config ["type" ]
348367 cls , config = storage_class_from_config (config )
349368 config ["collection" ] = collection
0 commit comments