Skip to content

Commit 06f012a

Browse files
committed
removed the file filter error
1 parent 49597a5 commit 06f012a

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

services/storage/src/simcore_service_storage/exceptions/errors.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,3 @@ class AccessLayerError(StorageRuntimeError):
4141

4242
class InvalidFileIdentifierError(AccessLayerError):
4343
msg_template: str = "Error in {identifier}: {details}"
44-
45-
46-
class FileFilterInvalidError(StorageRuntimeError):
47-
msg_template: str = (
48-
"Invalid filter `{file_filter}` used. "
49-
"\nTIP: currently only files starting with a project identifier are accepted."
50-
)

services/storage/src/simcore_service_storage/modules/db/file_meta_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ async def try_get_directory(
158158
# there should be only 1 entry if this is a directory
159159
result = await conn.execute(
160160
sa.select(file_meta_data).where(
161-
file_meta_data.c.file_id.startswith(f"{file_id}")
161+
file_meta_data.c.file_id == f"{file_id}"
162162
)
163163
)
164164
if row := result.one_or_none():
@@ -265,8 +265,9 @@ async def list_child_paths(
265265

266266
items = [
267267
PathMetaData(
268-
path=row.path,
269-
display_path=row.path,
268+
path=row.path
269+
or row.file_id, # NOTE: if path_prefix is partial then path is None
270+
display_path=row.path or row.file_id,
270271
location_id=row.location_id,
271272
location=row.location,
272273
bucket_name=row.bucket_name,

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
from .dsm_factory import BaseDataManager
5656
from .exceptions.errors import (
5757
FileAccessRightError,
58-
FileFilterInvalidError,
5958
FileMetaDataNotFoundError,
6059
LinkAlreadyExistsError,
6160
ProjectAccessRightError,
@@ -182,14 +181,12 @@ async def list_paths(
182181
) -> tuple[list[PathMetaData], PathCursor | None, TotalNumber | None]:
183182
"""returns a page of the file meta data a user has access to"""
184183

185-
# if we have a file_filter, that means that we have at least a partial project ID
184+
# if we have a file_filter, that means that we have potentially a project ID
186185
try:
187186
# NOTE: we currently do not support anything else than project_id/node_id/file_path here, sorry chap
188187
project_id = ProjectID(file_filter.parts[0]) if file_filter else None
189-
except ValueError as exc:
190-
raise FileFilterInvalidError(
191-
user_id=user_id, file_filter=file_filter
192-
) from exc
188+
except ValueError:
189+
project_id = None
193190

194191
next_cursor: PathCursor | None = None
195192
total: TotalNumber | None = None
@@ -224,7 +221,20 @@ async def list_paths(
224221
start_after=None,
225222
limit=limit,
226223
next_cursor=objects_cursor,
224+
is_partial_prefix=False,
227225
)
226+
if not list_s3_objects:
227+
list_s3_objects, objects_next_cursor = await get_s3_client(
228+
self.app
229+
).list_objects(
230+
bucket=self.simcore_bucket_name,
231+
prefix=file_filter,
232+
start_after=None,
233+
limit=limit,
234+
next_cursor=objects_cursor,
235+
is_partial_prefix=True,
236+
)
237+
228238
paths_metadata = [
229239
PathMetaData.from_s3_object_in_dir(s3_object, dir_fmd)
230240
for s3_object in list_s3_objects

0 commit comments

Comments
 (0)