@@ -455,6 +455,20 @@ def verify_user_peers(configuration, db_path, client_id, user, now, verify_peer,
455
455
return accepted_peer_list , effective_expire
456
456
457
457
458
+ def _check_directories_unprovisioned (configuration , db_path ):
459
+ user_db_home = os .path .dirname (db_path )
460
+ return not os .path .exists (db_path ) and not os .path .exists (user_db_home )
461
+
462
+
463
+ def _provision_directories (configuration ):
464
+ for config_attr in ('user_db_home' , 'user_home' , 'user_settings' , 'user_cache' , 'mrsl_files_dir' , 'resource_pending' ):
465
+ try :
466
+ dir_to_create = getattr (configuration , config_attr )
467
+ os .mkdir (dir_to_create )
468
+ except FileExistsError :
469
+ pass
470
+
471
+
458
472
def create_user_in_db (configuration , db_path , client_id , user , now , authorized ,
459
473
reset_token , reset_auth_type , accepted_peer_list , force ,
460
474
verbose , ask_renew , default_renew , do_lock ,
@@ -476,10 +490,8 @@ def create_user_in_db(configuration, db_path, client_id, user, now, authorized,
476
490
if oserr .errno != errno .ENOENT : # FileNotFoundError
477
491
raise
478
492
479
- user_db_home = os .path .dirname (db_path )
480
-
481
- if not os .path .exists (db_path ) and not os .path .exists (user_db_home ):
482
- os .mkdir (user_db_home )
493
+ if _check_directories_unprovisioned (configuration , db_path = db_path ):
494
+ _provision_directories (configuration )
483
495
retry_lock = True
484
496
else :
485
497
raise Exception ("Failed to lock user DB: '%s'" % db_path )
0 commit comments