@@ -232,10 +232,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
232
232
233
233
def save_status (base_path , pair , collection = None , data_type = None , data = None ):
234
234
assert data_type is not None
235
- assert data is not None
236
235
status_name = get_status_name (pair , collection )
237
236
path = expand_path (os .path .join (base_path , status_name )) + "." + data_type
238
237
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
239
244
240
245
with atomic_write (path , mode = "w" , overwrite = True ) as f :
241
246
json .dump (data , f )
@@ -335,6 +340,19 @@ def assert_permissions(path, wanted):
335
340
os .chmod (path , wanted )
336
341
337
342
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
+
338
356
async def handle_collection_not_found (config , collection , e = None ):
339
357
storage_name = config .get ("instance_name" , None )
340
358
@@ -344,7 +362,8 @@ async def handle_collection_not_found(config, collection, e=None):
344
362
)
345
363
)
346
364
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?" ):
348
367
storage_type = config ["type" ]
349
368
cls , config = storage_class_from_config (config )
350
369
config ["collection" ] = collection
0 commit comments