Symbolic link handling
This commit is contained in:
+17
-8
@@ -61,14 +61,23 @@ def get_file_info_list(path: Path, extensions: Optional[tuple] = None) -> List[D
|
||||
if extensions and not entry.name.lower().endswith(extensions):
|
||||
continue
|
||||
|
||||
stats = entry.stat()
|
||||
items.append({
|
||||
"name": entry.name,
|
||||
"path": entry,
|
||||
"mtime": stats.st_mtime,
|
||||
"size": stats.st_size,
|
||||
"is_dir": entry.is_dir()
|
||||
})
|
||||
try:
|
||||
stats = entry.lstat()
|
||||
is_link = entry.is_symlink()
|
||||
target = str(entry.readlink()) if is_link else None
|
||||
|
||||
items.append({
|
||||
"name": entry.name,
|
||||
"path": entry,
|
||||
"mtime": stats.st_mtime,
|
||||
"size": stats.st_size,
|
||||
"is_dir": entry.is_dir(),
|
||||
"is_link": is_link,
|
||||
"target": target
|
||||
})
|
||||
except Exception:
|
||||
# Skip items that are completely inaccessible
|
||||
continue
|
||||
except Exception as e:
|
||||
raise ToolError(f"Error accessing directory {path}: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user