mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #1925 from efiop/1655
stage: commit cached stage to avoid data duplication
This commit is contained in:
+15
-1
@@ -394,7 +394,21 @@ class Stage(object):
|
||||
out.pop(RemoteLOCAL.PARAM_CHECKSUM, None)
|
||||
out.pop(RemoteS3.PARAM_CHECKSUM, None)
|
||||
|
||||
return old_d == new_d
|
||||
if old_d != new_d:
|
||||
return False
|
||||
|
||||
# NOTE: committing to prevent potential data duplication. For example
|
||||
#
|
||||
# $ dvc config cache.type hardlink
|
||||
# $ echo foo > foo
|
||||
# $ dvc add foo
|
||||
# $ rm -f foo
|
||||
# $ echo foo > foo
|
||||
# $ dvc add foo # should replace foo with a link to cache
|
||||
#
|
||||
old.commit()
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def create(
|
||||
|
||||
@@ -475,3 +475,24 @@ class TestShouldNotTrackGitInternalFiles(TestDvc):
|
||||
created_stages_filenames = stage_creator_spy.mock.call_args[0][0]
|
||||
for fname in created_stages_filenames:
|
||||
self.assertNotIn(".git", fname)
|
||||
|
||||
|
||||
class TestAddUnprotected(TestDvc):
|
||||
def test(self):
|
||||
ret = main(["config", "cache.type", "hardlink"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(["config", "cache.protected", "true"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(["add", self.FOO])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(["unprotect", self.FOO])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
ret = main(["add", self.FOO])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
self.assertFalse(os.access(self.FOO, os.W_OK))
|
||||
self.assertTrue(System.is_hardlink(self.FOO))
|
||||
|
||||
Reference in New Issue
Block a user