mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-06 07:18:28 +01:00
Merge pull request #2462 from pared/2125
stage: don't unprotect outs on stage create
This commit is contained in:
@@ -505,8 +505,6 @@ class Stage(object):
|
||||
stage.remove_outs(ignore_remove=False)
|
||||
logger.warning("Build cache is ignored when using --remove-outs.")
|
||||
ignore_build_cache = True
|
||||
else:
|
||||
stage.unprotect_outs()
|
||||
|
||||
if os.path.exists(path) and any(out.persist for out in stage.outs):
|
||||
logger.warning("Build cache is ignored when persisting outputs.")
|
||||
|
||||
@@ -12,6 +12,7 @@ import posixpath
|
||||
import logging
|
||||
import colorama
|
||||
|
||||
from dvc.remote import RemoteLOCAL
|
||||
from dvc.system import System
|
||||
from mock import patch
|
||||
|
||||
@@ -535,3 +536,20 @@ def test_windows_should_add_when_cache_on_different_drive(
|
||||
|
||||
ret = main(["add", repo_dir.DATA])
|
||||
assert ret == 0
|
||||
|
||||
|
||||
def test_readding_dir_should_not_unprotect_all(dvc_repo, repo_dir):
|
||||
dvc_repo.cache.local.cache_types = ["symlink"]
|
||||
dvc_repo.cache.local.protected = True
|
||||
|
||||
dvc_repo.add(repo_dir.DATA_DIR)
|
||||
new_file = os.path.join(repo_dir.DATA_DIR, "new_file")
|
||||
|
||||
repo_dir.create(new_file, "new_content")
|
||||
|
||||
unprotect_spy = spy(RemoteLOCAL.unprotect)
|
||||
with patch.object(RemoteLOCAL, "unprotect", unprotect_spy):
|
||||
dvc_repo.add(repo_dir.DATA_DIR)
|
||||
|
||||
assert not unprotect_spy.mock.called
|
||||
assert System.is_symlink(new_file)
|
||||
|
||||
Reference in New Issue
Block a user