@@ -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 )
@@ -334,6 +339,19 @@ def assert_permissions(path, wanted):
334
339
os .chmod (path , wanted )
335
340
336
341
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
+
337
355
async def handle_collection_not_found (config , collection , e = None ):
338
356
storage_name = config .get ("instance_name" , None )
339
357
@@ -343,7 +361,8 @@ async def handle_collection_not_found(config, collection, e=None):
343
361
)
344
362
)
345
363
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?" ):
347
366
storage_type = config ["type" ]
348
367
cls , config = storage_class_from_config (config )
349
368
config ["collection" ] = collection
0 commit comments