Skip to content

Commit 325ae15

Browse files
fix pylint
1 parent d612a58 commit 325ae15

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
from .s3 import get_s3_client
8080
from .s3_utils import S3TransferDataCB, update_task_progress
8181
from .settings import Settings
82-
from .simcore_s3_dsm_utils import expand_directory, get_directory_file_id
82+
from .simcore_s3_dsm_utils import (
83+
expand_directory,
84+
find_enclosing_file,
85+
get_directory_file_id,
86+
)
8387
from .utils import (
8488
convert_db_to_model,
8589
download_to_file_or_raise,
@@ -499,22 +503,6 @@ async def __get_link(
499503

500504
return link
501505

502-
async def __find_enclosing_file(
503-
self, conn: SAConnection, user_id: UserID, file_id: SimcoreS3FileID
504-
) -> FileMetaDataAtDB | None:
505-
kwnon_files = {
506-
Path(known_file.file_id): known_file
507-
for known_file in await db_file_meta_data.list_fmds(conn, user_id=user_id)
508-
}
509-
current_path = Path(file_id)
510-
while current_path and current_path != Path(current_path).parent:
511-
if current_path in kwnon_files:
512-
return kwnon_files.get(current_path)
513-
514-
current_path = Path(current_path).parent
515-
516-
return None
517-
518506
async def delete_file(
519507
self,
520508
user_id: UserID,
@@ -539,7 +527,7 @@ async def delete_file(
539527
if not can.delete:
540528
raise FileAccessRightError(access_right="delete", file_id=file_id)
541529

542-
enclosing_file = await self.__find_enclosing_file(conn, user_id, file_id)
530+
enclosing_file = await find_enclosing_file(conn, user_id, file_id)
543531
if enclosing_file and enclosing_file.file_id == file_id:
544532
await db_file_meta_data.delete(conn, [file_id])
545533

services/storage/src/simcore_service_storage/simcore_s3_dsm_utils.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from . import db_file_meta_data
1616
from .exceptions import FileMetaDataNotFoundError
17-
from .models import FileMetaData, FileMetaDataAtDB
17+
from .models import FileMetaData, FileMetaDataAtDB, UserID
1818
from .utils import convert_db_to_model
1919

2020

@@ -119,3 +119,20 @@ async def _get_fmd(
119119
directory_file_id_fmd = await _get_fmd(conn, directory_file_id)
120120

121121
return directory_file_id if directory_file_id_fmd else None
122+
123+
124+
async def find_enclosing_file(
125+
conn: SAConnection, user_id: UserID, file_id: SimcoreS3FileID
126+
) -> FileMetaDataAtDB | None:
127+
kwnon_files = {
128+
Path(known_file.file_id): known_file
129+
for known_file in await db_file_meta_data.list_fmds(conn, user_id=user_id)
130+
}
131+
current_path = Path(file_id)
132+
while current_path and current_path != Path(current_path).parent:
133+
if current_path in kwnon_files:
134+
return kwnon_files.get(current_path)
135+
136+
current_path = Path(current_path).parent
137+
138+
return None

0 commit comments

Comments
 (0)