Skip to content

Commit 221a482

Browse files
committed
working
1 parent fa4c348 commit 221a482

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def compute_path_total_size(self, user_id: UserID, *, path: Path) -> ByteS
265265
# 4. path is complete and not in the DB --> entry in S3, returns directly from there
266266

267267
with contextlib.suppress(ValidationError):
268-
file_id = TypeAdapter(StorageFileID).validate_python(path)
268+
file_id = TypeAdapter(StorageFileID).validate_python(f"{path}")
269269
# path might be complete
270270
with contextlib.suppress(FileMetaDataNotFoundError):
271271
# file or folder is in DB

services/storage/tests/unit/test_handlers_paths.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ async def _assert_compute_path_total_size(
508508
*,
509509
path: Path,
510510
expected_total_size: int,
511-
) -> None:
511+
) -> ByteSize:
512512
url = url_from_operation_id(
513513
client,
514514
initialized_app,
@@ -526,6 +526,7 @@ async def _assert_compute_path_total_size(
526526
assert received
527527
assert received.path == path
528528
assert received.size == expected_total_size
529+
return received.size
529530

530531

531532
@pytest.mark.parametrize(
@@ -618,11 +619,38 @@ async def test_path_compute_size(
618619
expected_total_size = project_params.allowed_file_sizes[0] * len(
619620
selected_node_s3_keys
620621
)
621-
await _assert_compute_path_total_size(
622+
workspace_total_size = await _assert_compute_path_total_size(
622623
initialized_app,
623624
client,
624625
location_id,
625626
user_id,
626627
path=path,
627628
expected_total_size=expected_total_size,
628629
)
630+
631+
# get size of folders inside the workspace
632+
folders_inside_workspace = [
633+
p[0]
634+
for p in _filter_and_group_paths_one_level_deeper(selected_node_s3_keys, path)
635+
if p[1] is False
636+
]
637+
accumulated_subfolder_size = 0
638+
for workspace_subfolder in folders_inside_workspace:
639+
selected_node_s3_keys = [
640+
Path(s3_object_id)
641+
for s3_object_id in list_of_files[selected_node_id]
642+
if s3_object_id.startswith(f"{workspace_subfolder}")
643+
]
644+
expected_total_size = project_params.allowed_file_sizes[0] * len(
645+
selected_node_s3_keys
646+
)
647+
accumulated_subfolder_size += await _assert_compute_path_total_size(
648+
initialized_app,
649+
client,
650+
location_id,
651+
user_id,
652+
path=workspace_subfolder,
653+
expected_total_size=expected_total_size,
654+
)
655+
656+
assert workspace_total_size == accumulated_subfolder_size

0 commit comments

Comments
 (0)