Merge pull request #746 from efiop/master

checkout: create dir even if it is empty
This commit is contained in:
Ruslan Kuprieiev
2018-06-06 02:57:49 +03:00
committed by GitHub
2 changed files with 22 additions and 0 deletions
+5
View File
@@ -160,6 +160,11 @@ class RemoteLOCAL(RemoteBase):
msg = u'Checking out directory \'{}\' with cache \'{}\''
Logger.debug(msg.format(os.path.relpath(path), os.path.relpath(cache)))
# Create dir separately so that dir is created
# even if there are no files in it
if not os.path.exists(path):
os.makedirs(path)
dir_cache = self.dir_cache(cache)
for relpath, c in dir_cache.items():
p = os.path.join(path, relpath)
+17
View File
@@ -170,3 +170,20 @@ class TestCheckoutMissingMd5InStageFile(TestRepro):
yaml.dump(d, fd)
self.dvc.checkout()
class TestCheckoutEmptyDir(TestDvc):
def test(self):
dname = 'empty_dir'
os.mkdir(dname)
stage = self.dvc.add(dname)
self.assertEqual(len(stage.outs), 1)
stage.outs[0].remove()
self.assertFalse(os.path.exists(dname))
self.dvc.checkout()
self.assertTrue(os.path.isdir(dname))
self.assertEqual(len(os.listdir(dname)), 0)