@@ -227,10 +227,15 @@ def manage_sync_status(base_path, pair_name, collection_name):
227
227
228
228
def save_status (base_path , pair , collection = None , data_type = None , data = None ):
229
229
assert data_type is not None
230
- assert data is not None
231
230
status_name = get_status_name (pair , collection )
232
231
path = expand_path (os .path .join (base_path , status_name )) + "." + data_type
233
232
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
234
239
235
240
with atomic_write (path , mode = "w" , overwrite = True ) as f :
236
241
json .dump (data , f )
@@ -330,6 +335,19 @@ def assert_permissions(path, wanted):
330
335
os .chmod (path , wanted )
331
336
332
337
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
+
333
351
async def handle_collection_not_found (config , collection , e = None ):
334
352
storage_name = config .get ("instance_name" , None )
335
353
@@ -339,7 +357,8 @@ async def handle_collection_not_found(config, collection, e=None):
339
357
)
340
358
)
341
359
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?" ):
343
362
storage_type = config ["type" ]
344
363
cls , config = storage_class_from_config (config )
345
364
config ["collection" ] = collection
0 commit comments