add force option to movie reload
In case an import fails we need to skip checking whether the IMDb export dumps changed.
This commit is contained in:
parent
b2caaa8bc3
commit
181719c6d9
2 changed files with 6 additions and 3 deletions
|
|
@ -237,7 +237,7 @@ async def import_from_file(*, basics_path: Path, ratings_path: Path):
|
||||||
await db.set_import_progress(100)
|
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.
|
"""Refresh the full IMDb movie database.
|
||||||
|
|
||||||
The latest dumps are first downloaded and then imported into the 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
|
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)
|
await import_from_file(basics_path=basics_file, ratings_path=ratings_file)
|
||||||
|
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,9 @@ _import_lock = asyncio.Lock()
|
||||||
@requires(["authenticated", "admin"])
|
@requires(["authenticated", "admin"])
|
||||||
async def load_imdb_movies(request):
|
async def load_imdb_movies(request):
|
||||||
|
|
||||||
|
params = request.query_params
|
||||||
|
force = truthy(params.get("force"))
|
||||||
|
|
||||||
async with _import_lock:
|
async with _import_lock:
|
||||||
progress = await db.get_import_progress()
|
progress = await db.get_import_progress()
|
||||||
if progress and not progress.stopped:
|
if progress and not progress.stopped:
|
||||||
|
|
@ -368,7 +371,7 @@ async def load_imdb_movies(request):
|
||||||
|
|
||||||
await db.set_import_progress(0)
|
await db.set_import_progress(0)
|
||||||
|
|
||||||
task = BackgroundTask(imdb_import.load_from_web)
|
task = BackgroundTask(imdb_import.load_from_web, force=force)
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
{"status": "Import started.", "progress": 0.0}, background=task, status_code=202
|
{"status": "Import started.", "progress": 0.0}, background=task, status_code=202
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue