Skip to content

Commit

Permalink
index: fetch: validate localfs meta using md5 (#507)
Browse files Browse the repository at this point in the history
* index: fetch: validate localfs meta using md5

* Update fetch.py
  • Loading branch information
efiop authored Feb 15, 2024
1 parent 05afa6f commit 5fb53c7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dvc_data/index/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from functools import partial
from typing import TYPE_CHECKING, Optional, Set

from dvc_objects.fs.local import LocalFileSystem
from fsspec.callbacks import DEFAULT_CALLBACK

from dvc_data.callbacks import TqdmCallback
Expand Down Expand Up @@ -77,6 +78,15 @@ def _filter_changed(index):
meta = Meta.from_info(info)
old = getattr(entry.meta, data_fs.PARAM_CHECKSUM, None) if entry.meta else None
new = getattr(meta, data_fs.PARAM_CHECKSUM, None)

if old and new is None and isinstance(data_fs, LocalFileSystem):
# NOTE: temporary ugly hack to handle local sources where
# the only thing we currently have is md5.
from dvc_data.hashfile.hash import hash_file

_, hi = hash_file(data_path, data_fs, "md5")
new = hi.value

if old and new and old == new:
ret.add(entry)

Expand Down

0 comments on commit 5fb53c7

Please sign in to comment.