mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 23:10:10 +01:00
Merge pull request #746 from efiop/master
checkout: create dir even if it is empty
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user