Skip to content

Commit

Permalink
storage/reflink: _make_dir(): check isdir() for existing path
Browse files Browse the repository at this point in the history
  • Loading branch information
rustybird committed Jan 23, 2022
1 parent b50bcec commit 397fd95
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions qubes/storage/reflink.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,17 @@ def _replace_file(dst):
qubes.utils.remove_file, log_level=logging.INFO)

def _make_dir(path):
''' mkdir path, ignoring FileExistsError; return whether we
created it.
'''
with suppress(FileExistsError):
try:
created = False
os.mkdir(path)
created = True
except FileExistsError:
if not os.path.isdir(path):
raise
if created:
qubes.utils.fsync_path(os.path.dirname(path))
LOGGER.info('Created directory: %r', path)
return True
return False
return created

def _remove_empty_dir(path):
try:
Expand Down

0 comments on commit 397fd95

Please sign in to comment.