Skip to content

Commit

Permalink
Ignore special dotfiles at Zarr root when syncing at the end of a dow…
Browse files Browse the repository at this point in the history
…nload
  • Loading branch information
jwodder committed Oct 28, 2022
1 parent fb4dbc1 commit 10f3c94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .utils import (
abbrev_prompt,
ensure_datetime,
exclude_from_zarr,
flattened,
is_same_time,
on_windows,
Expand Down Expand Up @@ -879,7 +880,9 @@ def digest_callback(path: str, algoname: str, d: str) -> None:
d = dirs.popleft()
is_empty = True
for p in list(d.iterdir()):
if (
if d == zarr_basepath and exclude_from_zarr(p):
is_empty = False
elif (
p.is_file()
and p.relative_to(zarr_basepath).as_posix() not in remote_paths
):
Expand Down
2 changes: 1 addition & 1 deletion dandi/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def test_download_different_zarr_onto_excluded_dotfiles(
download(
zarr_dandiset.dandiset.version_api_url, tmp_path, existing="overwrite-different"
)
assert list_paths(zarr_path, dirs=True) == [
assert list_paths(zarr_path, dirs=True, exclude_vcs=False) == [
zarr_path / ".dandi",
zarr_path / ".dandi" / "somefile.txt",
zarr_path / ".datalad",
Expand Down
5 changes: 4 additions & 1 deletion dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ def good_file(path: str) -> bool:
yield p


def list_paths(dirpath: Union[str, Path], dirs: bool = False) -> List[Path]:
def list_paths(
dirpath: Union[str, Path], dirs: bool = False, exclude_vcs: bool = True
) -> List[Path]:
return sorted(
map(
Path,
Expand All @@ -366,6 +368,7 @@ def list_paths(dirpath: Union[str, Path], dirs: bool = False) -> List[Path]:
dirs=dirs,
exclude_dotfiles=False,
exclude_dotdirs=False,
exclude_vcs=exclude_vcs,
),
)
)
Expand Down

0 comments on commit 10f3c94

Please sign in to comment.