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

syscontainers: ensure destdir exist #1140

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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