Symbolic link handling

This commit is contained in:
2026-09-22 12:53:29 -07:00
parent 73a06f3c94
commit 6c33951c81
2 changed files with 28 additions and 10 deletions
+11 -2
View File
@@ -48,16 +48,25 @@ async def handle(args: Dict[str, Any]):
output = []
for item in paged_items:
mtime_rel = format_relative_time(item["mtime"])
# Handle symbolic links in the display name
display_name = item["name"]
if item.get("is_link"):
target = item["target"]
is_broken = not item["path"].exists()
broken_str = " (BROKEN)" if is_broken else ""
display_name = f"{item['name']} -> {target}{broken_str}"
if item["is_dir"]:
try:
count = len(list(item["path"].iterdir()))
info = f"{count} items"
except:
info = "0 items"
output.append(f"[DIR] {item['name']} | {info} | {mtime_rel}")
output.append(f"[DIR] {display_name} | {info} | {mtime_rel}")
else:
size_kb = item["size"] / 1024
output.append(f" {item['name']} | {size_kb:.1f}KB | {mtime_rel}")
output.append(f" {display_name} | {size_kb:.1f}KB | {mtime_rel}")
header = f"Listing of {path}\nPage {effective_page} of {total_pages} ({total_items} total items). Showing {start_idx+1}-{min(end_idx, total_items)}."