mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-17 07:18:26 +01:00
Merge pull request #3054 from sharidas/fix-gc-local
dvc: update gc to remove unpacked dir
This commit is contained in:
@@ -697,6 +697,8 @@ class RemoteBASE(object):
|
||||
if checksum in used:
|
||||
continue
|
||||
path_info = self.checksum_to_path_info(checksum)
|
||||
if self.is_dir_checksum(checksum):
|
||||
self._remove_unpacked_dir(checksum)
|
||||
self.remove(path_info)
|
||||
removed = True
|
||||
return removed
|
||||
@@ -1009,3 +1011,6 @@ class RemoteBASE(object):
|
||||
|
||||
def _update_unpacked_dir(self, checksum):
|
||||
pass
|
||||
|
||||
def _remove_unpacked_dir(self, checksum):
|
||||
pass
|
||||
|
||||
@@ -464,6 +464,10 @@ class RemoteLOCAL(RemoteBASE):
|
||||
info = self.checksum_to_path_info(checksum)
|
||||
return info.with_name(info.name + self.UNPACKED_DIR_SUFFIX)
|
||||
|
||||
def _remove_unpacked_dir(self, checksum):
|
||||
path_info = self._get_unpacked_dir_path_info(checksum)
|
||||
self.remove(path_info)
|
||||
|
||||
def _path_info_changed(self, path_info):
|
||||
if self.exists(path_info) and self.state.get(path_info):
|
||||
return False
|
||||
|
||||
@@ -7,6 +7,7 @@ from git import Repo
|
||||
from dvc.exceptions import CollectCacheError
|
||||
from dvc.main import main
|
||||
from dvc.repo import Repo as DvcRepo
|
||||
from dvc.remote.local import RemoteLOCAL
|
||||
from tests.basic_env import TestDir, TestDvcGit
|
||||
|
||||
|
||||
@@ -204,3 +205,18 @@ def test_gc_no_dir_cache(tmp_dir, dvc, repo_template):
|
||||
|
||||
def _count_files(path):
|
||||
return sum(len(files) for _, _, files in os.walk(path))
|
||||
|
||||
|
||||
def test_gc_no_unpacked_dir(tmp_dir, dvc, repo_template):
|
||||
dir_stages = dvc.add("dir")
|
||||
dvc.status()
|
||||
|
||||
os.remove("dir.dvc")
|
||||
unpackeddir = (
|
||||
dir_stages[0].outs[0].cache_path + RemoteLOCAL.UNPACKED_DIR_SUFFIX
|
||||
)
|
||||
|
||||
assert os.path.exists(unpackeddir)
|
||||
|
||||
dvc.gc(force=True)
|
||||
assert not os.path.exists(unpackeddir)
|
||||
|
||||
Reference in New Issue
Block a user