Skip to content

Commit

Permalink
repo: add basic cache_check_missing
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Aug 7, 2023
1 parent 722839d commit 024df3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Repo:
from dvc.repo.status import status # type: ignore[misc]
from dvc.repo.update import update # type: ignore[misc]

from .cache import check_missing as cache_check_missing # type: ignore[misc]
from .data import status as data_status # type: ignore[misc]

ls = staticmethod(_ls)
Expand Down
25 changes: 25 additions & 0 deletions dvc/repo/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os


def check_missing(repo, rev=None):
from dvc_data.index import StorageKeyError

with repo.switch(rev or "workspace"):
index = repo.index.data["repo"]

def onerror(_entry, _exc):
pass

index.onerror = onerror

ret = []
for _, entry in index.iteritems():
try:
fs, path = index.storage_map.get_cache(entry)
except (StorageKeyError, ValueError):
continue

if not fs.exists(path):
ret.append(os.path.join(*entry.key))

return ret

0 comments on commit 024df3d

Please sign in to comment.