Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix common path in _ ls_tree #1850

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/huggingface_hub/hf_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections import deque
from dataclasses import dataclass
from datetime import datetime
from itertools import chain
from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union
from urllib.parse import quote, unquote

Expand Down Expand Up @@ -323,7 +324,9 @@ def _ls_tree(
# Get the parent directory if the common prefix itself is not a directory
common_path = (
common_prefix.rstrip("/")
if common_prefix.endswith("/") or common_prefix == root_path
if common_prefix.endswith("/")
or common_prefix == root_path
or common_prefix in chain(dirs_not_in_dircache, dirs_not_expanded)
else self._parent(common_prefix)
)
out = [o for o in out if not o["name"].startswith(common_path + "/")]
Expand Down
Loading