Skip to content

Commit 6a2cef3

Browse files
committed
GetPackByFileNamePrefixAction fast break
1 parent 5dd090e commit 6a2cef3

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

prime_backup/action/get_pack_action.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from abc import ABC, abstractmethod
2+
from typing import List
23

34
from typing_extensions import override
45

@@ -40,11 +41,12 @@ def __init__(self, pack_file_name_prefix: str):
4041

4142
@override
4243
def _do_get_pack(self, session: DbSession) -> schema.Pack:
43-
matched_pack_ids = [
44-
pack_id
45-
for pack_id in session.get_all_pack_ids()
46-
if pack_utils.get_pack_file_name(pack_id).startswith(self.pack_file_name_prefix)
47-
]
44+
matched_pack_ids: List[int] = []
45+
for pack_id in session.get_all_pack_ids():
46+
if pack_utils.get_pack_file_name(pack_id).startswith(self.pack_file_name_prefix):
47+
matched_pack_ids.append(pack_id)
48+
if len(matched_pack_ids) >= 3:
49+
break
4850
if len(matched_pack_ids) == 0:
4951
raise PackFileNameNotFound(self.pack_file_name_prefix)
5052
if len(matched_pack_ids) > 1:

0 commit comments

Comments
 (0)