Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.11] Revert "utils/fs: checking files ownership in 'move' (#4348) (#4832)" #5321

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ def __init__(self, path, hint=None):
)


class FileOwnershipError(DvcException):
def __init__(self, path):
super().__init__(f"file '{path}' not owned by user! ")


class DvcIgnoreInCollectedDirError(DvcException):
def __init__(self, ignore_dirname):
super().__init__(
Expand Down
16 changes: 5 additions & 11 deletions dvc/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import nanotime
from shortuuid import uuid

from dvc.exceptions import DvcException, FileOwnershipError
from dvc.exceptions import DvcException
from dvc.system import System
from dvc.utils import dict_md5

Expand Down Expand Up @@ -95,21 +95,15 @@ def move(src, dst, mode=None):
dst = os.path.abspath(dst)
tmp = f"{dst}.{uuid()}"

try:
if mode is not None:
os.chmod(src, mode)
except OSError as e:
if e.errno not in [errno.EACCES, errno.EPERM]:
raise
else:
raise FileOwnershipError(src)

if os.path.islink(src):
shutil.copy(src, tmp)
_unlink(src, _chmod)
os.unlink(src)
else:
shutil.move(src, tmp)

if mode is not None:
os.chmod(tmp, mode)

shutil.move(tmp, dst)


Expand Down