mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-06-12 19:55:17 +02:00
fix(filesystem): render root folder path correctly
This commit is contained in:
parent
ec96812e6b
commit
8ae94ade19
2 changed files with 17 additions and 2 deletions
|
|
@ -817,16 +817,20 @@ class PIFSCommandExecutor:
|
|||
if data and isinstance(data[0], dict) and "path" in data[0] and "file_ref" not in data[0]:
|
||||
return "\n".join(
|
||||
(
|
||||
f"{item['path']}/ matched_files={item['matched_files']} "
|
||||
f"{self._folder_row_path(item['path'])} matched_files={item['matched_files']} "
|
||||
f"files={item.get('file_count', 0)}"
|
||||
if item.get("matched_files")
|
||||
else f"{item['path']}/ folders={item.get('children_count', 0)} "
|
||||
else f"{self._folder_row_path(item['path'])} folders={item.get('children_count', 0)} "
|
||||
f"files={item.get('file_count', 0)}"
|
||||
)
|
||||
for item in data
|
||||
)
|
||||
return "\n".join(self._file_row_text(item) for item in data)
|
||||
|
||||
def _folder_row_path(self, path: str) -> str:
|
||||
normalized = self._normalize_folder_path(path)
|
||||
return "/" if normalized == "/" else f"{normalized}/"
|
||||
|
||||
def _render_stat(self, data: Any) -> str:
|
||||
if not isinstance(data, dict):
|
||||
return str(data)
|
||||
|
|
|
|||
|
|
@ -106,6 +106,17 @@ def test_find_maxdepth_zero_type_directory_returns_start_folder(tmp_path):
|
|||
assert [row["path"] for row in rows] == ["/documents"]
|
||||
|
||||
|
||||
def test_find_directory_output_renders_root_without_double_slash(tmp_path):
|
||||
executor = _register_find_fixture(tmp_path)
|
||||
executor.json_output = False
|
||||
|
||||
output = executor.execute("find / -maxdepth 1 -type d")
|
||||
|
||||
assert output.splitlines()[0] == "/ folders=1 files=0"
|
||||
assert "//" not in output
|
||||
assert "/documents/ folders=1 files=1" in output
|
||||
|
||||
|
||||
def test_find_maxdepth_combines_with_where_and_limit(tmp_path):
|
||||
executor = _register_find_fixture(tmp_path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue