feat & Bugfix: layout en rename (year)
This commit is contained in:
@@ -83,6 +83,53 @@ class FileDiscoveryService:
|
||||
"items": files,
|
||||
}
|
||||
|
||||
def list_folders(
|
||||
self,
|
||||
root_id: str,
|
||||
subpath: str = "",
|
||||
limit: int = 500,
|
||||
) -> dict:
|
||||
root = self._get_root_by_id(root_id)
|
||||
target = self._resolve_target(root["path"], subpath)
|
||||
|
||||
folders = []
|
||||
if not target.exists():
|
||||
return {
|
||||
"root_id": root["id"],
|
||||
"root_path": str(root["path"]),
|
||||
"subpath": subpath,
|
||||
"limit": limit,
|
||||
"items": folders,
|
||||
}
|
||||
if not target.is_dir():
|
||||
raise ValueError("resolved target is not a directory")
|
||||
|
||||
for entry in target.iterdir():
|
||||
if len(folders) >= limit:
|
||||
break
|
||||
if not entry.is_dir():
|
||||
continue
|
||||
try:
|
||||
relative_to_root = entry.resolve().relative_to(root["path"])
|
||||
except ValueError:
|
||||
continue
|
||||
folders.append(
|
||||
{
|
||||
"name": entry.name,
|
||||
"subpath": str(relative_to_root),
|
||||
"path": str(entry),
|
||||
}
|
||||
)
|
||||
|
||||
folders.sort(key=lambda x: x["name"].lower())
|
||||
return {
|
||||
"root_id": root["id"],
|
||||
"root_path": str(root["path"]),
|
||||
"subpath": subpath,
|
||||
"limit": limit,
|
||||
"items": folders,
|
||||
}
|
||||
|
||||
def _load_allowed_extensions(self) -> set[str]:
|
||||
raw = os.getenv("ALLOWED_EXTENSIONS", "").strip()
|
||||
if raw:
|
||||
|
||||
Reference in New Issue
Block a user