diff --git a/unwind/imdb_import.py b/unwind/imdb_import.py index e29a981..0292716 100644 --- a/unwind/imdb_import.py +++ b/unwind/imdb_import.py @@ -237,7 +237,7 @@ async def import_from_file(*, basics_path: Path, ratings_path: Path): await db.set_import_progress(100) -async def load_from_web(): +async def load_from_web(*, force: bool = False): """Refresh the full IMDb movie database. The latest dumps are first downloaded and then imported into the database. @@ -267,7 +267,7 @@ async def load_from_web(): or bastics_mtime != basics_file.stat().st_mtime ) - if is_changed: + if force or is_changed: await import_from_file(basics_path=basics_file, ratings_path=ratings_file) except BaseException as err: diff --git a/unwind/web.py b/unwind/web.py index b8306ef..efbbb13 100644 --- a/unwind/web.py +++ b/unwind/web.py @@ -358,6 +358,9 @@ _import_lock = asyncio.Lock() @requires(["authenticated", "admin"]) async def load_imdb_movies(request): + params = request.query_params + force = truthy(params.get("force")) + async with _import_lock: progress = await db.get_import_progress() if progress and not progress.stopped: @@ -368,7 +371,7 @@ async def load_imdb_movies(request): await db.set_import_progress(0) - task = BackgroundTask(imdb_import.load_from_web) + task = BackgroundTask(imdb_import.load_from_web, force=force) return JSONResponse( {"status": "Import started.", "progress": 0.0}, background=task, status_code=202 )