Skip to content

Commit

Permalink
Handle cross-drive windows permissions issues by undoing git's readon…
Browse files Browse the repository at this point in the history
…ly settings

automatic commit by git-black, original commits:
  d35e549
  • Loading branch information
Jacob Beck authored and iknox-fa committed Feb 8, 2022
1 parent 2b627d9 commit 449be4b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/dbt/clients/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def chmod_and_retry(func, path, exc_info):
We want to retry most operations here, but listdir is one that we know will
be useless.
"""
if func is os.listdir or os.name != 'nt':
if func is os.listdir or os.name != "nt":
raise
os.chmod(path, stat.S_IREAD | stat.S_IWRITE)
# on error,this will raise.
Expand All @@ -506,15 +506,15 @@ def move(src, dst):
"""
src = convert_path(src)
dst = convert_path(dst)
if os.name != 'nt':
if os.name != "nt":
return shutil.move(src, dst)

if os.path.isdir(dst):
if _absnorm(src) == _absnorm(dst):
os.rename(src, dst)
return

dst = os.path.join(dst, os.path.basename(src.rstrip('/\\')))
dst = os.path.join(dst, os.path.basename(src.rstrip("/\\")))
if os.path.exists(dst):
raise EnvironmentError("Path '{}' already exists".format(dst))

Expand All @@ -526,8 +526,7 @@ def move(src, dst):
if _absnorm(dst + "\\").startswith(_absnorm(src + "\\")):
# dst is inside src
raise EnvironmentError(
"Cannot move a directory '{}' into itself '{}'"
.format(src, dst)
"Cannot move a directory '{}' into itself '{}'".format(src, dst)
)
shutil.copytree(src, dst, symlinks=True)
rmtree(src)
Expand Down

0 comments on commit 449be4b

Please sign in to comment.