Skip to content

Commit

Permalink
syscontainers: ensure destdir exists
Browse files Browse the repository at this point in the history
Closes: projectatomic#1138

Closes: projectatomic#1140
Approved by: miabbott
  • Loading branch information
ashcrow authored and eyusupov committed Mar 10, 2018
1 parent 7b652f2 commit 0023634
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,17 +688,20 @@ def _is_repo_on_the_same_filesystem(repo, destdir):
:type destdir: str
"""
repo_stat = os.stat(repo)
destdir_stat = os.stat(destdir)
try:
destdir_stat = os.stat(destdir)
except OSError as e:
if e.errno == errno.ENOENT:
# The directory doesn't exist
os.makedirs(destdir)
destdir_stat = os.stat(destdir)
else:
raise e

# Simple case: st_dev is different
if repo_stat.st_dev != destdir_stat.st_dev:
return False

try:
os.makedirs(destdir)
except OSError as e:
if e.errno != errno.EEXIST:
raise

src_file = os.path.join(repo, "config")
dest_file = os.path.join(destdir, "samefs-check-{}".format(os.getpid()))
# Try to create a link, check if it fails with EXDEV
Expand Down

0 comments on commit 0023634

Please sign in to comment.