From 563c7f22196fb7d5bf7e025600d4f6b52cdfe89f Mon Sep 17 00:00:00 2001 From: Renato Date: Wed, 13 Sep 2023 13:26:39 +0800 Subject: [PATCH] Fix folder path logic error --- src/documents/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/documents/views.py b/src/documents/views.py index f3a7bb9fb..f963d36be 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1001,10 +1001,14 @@ class FilesAndFoldersViewSet(ReadOnlyModelViewSet): # parent_folder = request.query_params.get('path__istartswith', '') if parent_storage_path_id: + folders = [] parent_storage_path = StoragePath.objects.get(id=parent_storage_path_id) - folders = list(StoragePath.objects + child_folders = list(StoragePath.objects .filter(path__istartswith=parent_storage_path.path) .exclude(id=parent_storage_path.id)) + for f in child_folders: + if len(f.path.replace(parent_storage_path.path, '').split('/')) == 2: + folders.append(f) files = list(Document.objects.all().filter(storage_path=parent_storage_path).order_by(ordering)) else: folders = list(StoragePath.objects.exclude(path__contains='/'))