From 1cf50da68fabce7ebf5dda6452a412a825b4a2b0 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 20 Dec 2023 22:36:24 +0200 Subject: [PATCH] index: push: make sure cache files exist --- src/dvc_data/index/push.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/dvc_data/index/push.py b/src/dvc_data/index/push.py index b346e730..17868769 100644 --- a/src/dvc_data/index/push.py +++ b/src/dvc_data/index/push.py @@ -10,7 +10,7 @@ from .build import build from .checkout import apply, compare from .fetch import _log_missing -from .index import ObjectStorage +from .index import DataIndex, ObjectStorage if TYPE_CHECKING: from dvc_objects.fs import FileSystem @@ -83,9 +83,20 @@ def push( failed += len(result.failed) else: old = build(data.path, data.fs) + + existing_fs_index = DataIndex() + existing_fs_index.storage_map = fs_index.storage_map + for _, entry in fs_index.items(): + try: + cache_fs, cache_path = fs_index.storage_map.get_cache(entry) + except ValueError: + continue + if cache_fs.exists(cache_path): + existing_fs_index.add(entry) + diff = compare( old, - fs_index, + existing_fs_index, meta_only=True, meta_cmp_key=partial(_meta_checksum, data.fs), )