feat: upload - deel 03

This commit is contained in:
kodi
2026-03-13 16:41:04 +01:00
parent b635a79b63
commit 0591db4b2f
5 changed files with 36 additions and 9 deletions
+9 -2
View File
@@ -1,4 +1,5 @@
import os
import re
from pathlib import Path
@@ -49,8 +50,6 @@ class FileDiscoveryService:
iterator = target.iterdir()
for entry in iterator:
if len(files) >= limit:
break
if not entry.is_file():
continue
ext = entry.suffix.lower()
@@ -74,6 +73,10 @@ class FileDiscoveryService:
}
)
files.sort(key=lambda item: self._natural_sort_key(item.get("relative_path", "")))
if len(files) > limit:
files = files[:limit]
return {
"root_id": root["id"],
"root_path": str(root["path"]),
@@ -83,6 +86,10 @@ class FileDiscoveryService:
"items": files,
}
def _natural_sort_key(self, value: str):
text = str(value or "")
return [int(part) if part.isdigit() else part.lower() for part in re.split(r"(\d+)", text)]
def list_folders(
self,
root_id: str,