File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ def run(self, updatehash=False):
395
395
self ._interface .can_resume and op .isfile (hashfile_unfinished ))
396
396
397
397
if rm_outdir :
398
- emptydirs (outdir )
398
+ emptydirs (outdir , noexist_ok = True )
399
399
else :
400
400
logger .debug ('[%sNode] Resume - hashfile=%s' ,
401
401
'Map' * int (isinstance (self , MapNode )),
Original file line number Diff line number Diff line change @@ -699,18 +699,22 @@ def makedirs(path, exist_ok=False):
699
699
return path
700
700
701
701
702
- def emptydirs (path ):
702
+ def emptydirs (path , noexist_ok = False ):
703
703
"""
704
- Empty an existing directory, without deleting it
704
+ Empty an existing directory, without deleting it. Do not
705
+ raise error if the path does not exist and noexist_ok is True.
705
706
706
707
Parameters
707
708
----------
708
709
path : directory that should be empty
709
710
710
711
"""
711
712
fmlogger .debug ("Removing contents of %s" , path )
712
- pathconts = os .listdir (path )
713
713
714
+ if noexist_ok and not os .path .exists (path ):
715
+ return True
716
+
717
+ pathconts = os .listdir (path )
714
718
if not pathconts :
715
719
return True
716
720
You can’t perform that action at this time.
0 commit comments