Skip to content

Commit aa29c81

Browse files
authored
fixes #78, but maybe we rethink this together: (#90)
* fixes #78, but our progress levels / stages are not super intuitive: we already modify the library at the end of "waiting for user selection" - at which point apply_choice is invoked (does not move files, but adds to library) * test album count * added fixme comment for a future refactor
1 parent f7bc8bd commit aa29c81

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

backend/beets_flask/importer/progress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Progress(Enum):
3838

3939
# ImportSession
4040
OFFERING_MATCHES = 30
41-
WAITING_FOR_USER_SELECTION = 31
42-
MATCH_THRESHOLD = 32
41+
MATCH_THRESHOLD = 31
42+
WAITING_FOR_USER_SELECTION = 32
4343
EARLY_IMPORTING = 33
4444
IMPORTING = 34
4545
MANIPULATING_FILES = 35

backend/beets_flask/importer/session.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def __init__(
844844
@property
845845
def stages(self):
846846
stages = super().stages
847-
stages.insert(after="user_query", stage=match_threshold(self))
847+
stages.insert(before="user_query", stage=match_threshold(self))
848848
return stages
849849

850850
def match_threshold(self, task: importer.ImportTask):
@@ -856,6 +856,11 @@ def match_threshold(self, task: importer.ImportTask):
856856
or raise an exception.
857857
858858
Currently raising, as we do not have a dedicated progress for "not imported".
859+
860+
FIXME: Instead of adding a whole new stage, with progress and a session function,
861+
we could simply extend the choose_match function. It's defined for the normal
862+
import session, and gets called early in user_query.
863+
(see #78)
859864
"""
860865
try:
861866
task_state = self.state.get_task_state_for_task(task)

backend/tests/integration/test_flows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ async def test_import_auto_accept(self, db_session: Session, path: Path):
612612
assert len(self.statuses) == 4
613613
assert self.statuses[2].status == FolderStatus.IMPORTING
614614
assert self.statuses[3].status == FolderStatus.FAILED
615+
assert len(self.beets_lib.albums()) == 0
615616

616617
await run_import_auto(
617618
"obsolete_hash_import_auto",
@@ -623,6 +624,7 @@ async def test_import_auto_accept(self, db_session: Session, path: Path):
623624
assert len(self.statuses) == 6
624625
assert self.statuses[4].status == FolderStatus.IMPORTING
625626
assert self.statuses[5].status == FolderStatus.IMPORTED
627+
assert len(self.beets_lib.albums()) == 1
626628

627629

628630
class TestChooseCandidatesSingleTask(

0 commit comments

Comments
 (0)