Skip to content

Commit

Permalink
Fix common path in _ ls_tree (#1850)
Browse files Browse the repository at this point in the history
* fix common path in _ls_tree

* style
  • Loading branch information
lhoestq authored Nov 21, 2023
1 parent a9e9b71 commit 8831137
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 8831137

Please sign in to comment.