Skip to content

Commit 397fd95

Browse files
committed
storage/reflink: _make_dir(): check isdir() for existing path
1 parent b50bcec commit 397fd95

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

qubes/storage/reflink.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,17 @@ def _replace_file(dst):
369369
qubes.utils.remove_file, log_level=logging.INFO)
370370

371371
def _make_dir(path):
372-
''' mkdir path, ignoring FileExistsError; return whether we
373-
created it.
374-
'''
375-
with suppress(FileExistsError):
372+
try:
373+
created = False
376374
os.mkdir(path)
375+
created = True
376+
except FileExistsError:
377+
if not os.path.isdir(path):
378+
raise
379+
if created:
377380
qubes.utils.fsync_path(os.path.dirname(path))
378381
LOGGER.info('Created directory: %r', path)
379-
return True
380-
return False
382+
return created
381383

382384
def _remove_empty_dir(path):
383385
try:

0 commit comments

Comments
 (0)