mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #1752 from ei-grad/unprotect-improvement
unprotect: copy should preceed the move
This commit is contained in:
@@ -13,13 +13,16 @@ from dvc.exceptions import DvcException
|
||||
def _unprotect_file(path):
|
||||
if System.is_symlink(path) or System.is_hardlink(path):
|
||||
logger.debug("Unprotecting '{}'".format(path))
|
||||
|
||||
tmp = os.path.join(os.path.dirname(path), "." + str(uuid.uuid4()))
|
||||
move(path, tmp)
|
||||
|
||||
copyfile(tmp, path)
|
||||
# The operations order is important here - if some application would
|
||||
# access the file during the process of copyfile then it would get
|
||||
# only the part of file. So, at first, the file should be copied with
|
||||
# the temporary name, and then original file should be replaced by new.
|
||||
copyfile(path, tmp)
|
||||
remove(path)
|
||||
move(tmp, path)
|
||||
|
||||
remove(tmp)
|
||||
else:
|
||||
logger.debug(
|
||||
"Skipping copying for '{}', since it is not "
|
||||
|
||||
Reference in New Issue
Block a user