mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
+9
-2
@@ -284,10 +284,17 @@ class Output(Dependency):
|
||||
md5 = file_md5(path)[0]
|
||||
cache = self.project.cache.get(md5)
|
||||
cache_info = os.path.join(self.cache, relpath)
|
||||
cache_dir = os.path.dirname(cache_info)
|
||||
|
||||
self.hardlink(path, cache)
|
||||
if os.path.exists(cache):
|
||||
self._remove(path, None)
|
||||
self.hardlink(cache, path)
|
||||
else:
|
||||
self.hardlink(path, cache)
|
||||
|
||||
if not os.path.exists(cache_dir):
|
||||
os.makedirs(cache_dir)
|
||||
|
||||
os.makedirs(os.path.dirname(cache_info))
|
||||
with open(cache_info, 'w') as fd:
|
||||
yaml.safe_dump({self.PARAM_MD5: md5}, fd, default_flow_style=False)
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ coverage==4.3.1
|
||||
codeclimate-test-reporter==0.2.3
|
||||
xmltodict==0.11.0
|
||||
awscli==1.14.18
|
||||
pywin32; sys_platform == 'nt'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import stat
|
||||
import shutil
|
||||
import filecmp
|
||||
from checksumdir import dirhash
|
||||
@@ -59,6 +60,25 @@ class TestAddTrackedFile(TestDvc):
|
||||
self.dvc.add(fname)
|
||||
|
||||
|
||||
class TestAddDirWithExistingCache(TestDvc):
|
||||
def test(self):
|
||||
dname = 'a'
|
||||
fname = os.path.join(dname, 'b')
|
||||
os.mkdir(dname)
|
||||
shutil.copyfile(self.FOO, fname)
|
||||
|
||||
self.dvc.add(self.FOO)
|
||||
self.dvc.add(dname)
|
||||
|
||||
|
||||
class TestAddModifiedDir(TestDvc):
|
||||
def test(self):
|
||||
self.dvc.add(self.DATA_DIR)
|
||||
os.chmod(self.DATA, stat.S_IWRITE)
|
||||
os.unlink(self.DATA)
|
||||
self.dvc.add(self.DATA_DIR)
|
||||
|
||||
|
||||
class TestCmdAdd(TestDvc):
|
||||
def test(self):
|
||||
ret = main(['add',
|
||||
|
||||
Reference in New Issue
Block a user