From e939e57a8f93659bc6156ef68d361b93ac65ba44 Mon Sep 17 00:00:00 2001 From: ducklet Date: Tue, 27 Jul 2021 23:47:34 +0200 Subject: [PATCH] fix creating dud progress entries When the import process finishes it can set progress to 100 multiple times. The first call would add a stop time to the running progress, but each further call with progress=100 would create another entry in the table with stop already set. --- unwind/db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unwind/db.py b/unwind/db.py index e322238..0c96618 100644 --- a/unwind/db.py +++ b/unwind/db.py @@ -136,6 +136,12 @@ async def set_import_progress(progress: float) -> Progress: progress = min(max(0.0, progress), 100.0) # clamp to 0 <= progress <= 100 current = await get_import_progress() + is_stopped = current and current.stopped is not None + + if progress == 100.0 and is_stopped: + assert current + return current + is_update = current and current.stopped is None if not current or not is_update: