Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

Commit 436cf5d

Browse files
ashcrowrh-atomic-bot
authored andcommitted
syscontainers: ensure destdir exists
Closes: #1138 Closes: #1140 Approved by: miabbott
1 parent e5124cc commit 436cf5d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Atomic/syscontainers.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,17 +688,20 @@ def _is_repo_on_the_same_filesystem(repo, destdir):
688688
:type destdir: str
689689
"""
690690
repo_stat = os.stat(repo)
691-
destdir_stat = os.stat(destdir)
691+
try:
692+
destdir_stat = os.stat(destdir)
693+
except OSError as e:
694+
if e.errno == errno.ENOENT:
695+
# The directory doesn't exist
696+
os.makedirs(destdir)
697+
destdir_stat = os.stat(destdir)
698+
else:
699+
raise e
700+
692701
# Simple case: st_dev is different
693702
if repo_stat.st_dev != destdir_stat.st_dev:
694703
return False
695704

696-
try:
697-
os.makedirs(destdir)
698-
except OSError as e:
699-
if e.errno != errno.EEXIST:
700-
raise
701-
702705
src_file = os.path.join(repo, "config")
703706
dest_file = os.path.join(destdir, "samefs-check-{}".format(os.getpid()))
704707
# Try to create a link, check if it fails with EXDEV

0 commit comments

Comments
 (0)