From c36ae73301541ab08520c306d306a1075765dcde Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 24 Jan 2021 23:22:17 +0200 Subject: [PATCH] Revert "utils/fs: checking files ownership in 'move' (#4348) (#4832)" (#5321) Fixes #5255 We need a proper solution for #4832, will introduce later. This reverts commit 8e738262adf78f081473d32419c2fbc07811da4b. --- dvc/exceptions.py | 5 ----- dvc/utils/fs.py | 16 +++++----------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 7e6a5745e5..1a4a44f99d 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -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__( diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py index a5cdf1ca88..d80bce6ede 100644 --- a/dvc/utils/fs.py +++ b/dvc/utils/fs.py @@ -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 @@ -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)