mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 02:48:38 -04:00
Request sessions keep objects after commit; guard dict() serializers (#811)
A RequestSession no longer expires loaded objects at commit, so a handler serializes what it committed without a reload query. An AsyncSession cannot run that reload at all, so this is groundwork for moving request handling to async. Background sessions (get_db_session) keep SQLAlchemy's default: they change data outside the ORM (raw SQL, triggers) and rely on the reload. Collection, CollectionItem and Channel dict() now run inside the serializer guard. Fixes it found: - Channel.dict() no longer loads the deferred yt-dlp catalog (info_json), which the channel handler loaded only to discard. - get_channel eager-loads what Channel.dict() reads (populate_existing replaces a refresh query). - create_channel / get_or_create_download link through relationships, so a loaded Collection.downloads stays current. - Setting a Repo to Never removes the deleted Download from the loaded collection; the response reported the old frequency. - The downloader no longer calls channel.dict() to preload a Channel; its callers read it inside the session. Tests run each request with expiry off, as production does, and turn it back on for the background work that shares the test Session. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1f8a887c11
commit
673c23188c
13 changed files with 82 additions and 31 deletions
|
|
@ -738,6 +738,8 @@ def _set_repository_download(session: Session, repo: Repository, frequency: int,
|
|||
(`frequency` is NEVER) has none; with `clone`, it is cloned once if its clone is missing."""
|
||||
if not frequency:
|
||||
if download := repo.download:
|
||||
# A deleted object stays in loaded collections; remove it so the Repo reads as never updated.
|
||||
repo.collection.downloads.remove(download)
|
||||
session.delete(download)
|
||||
if clone and not (repo.directory / '.git').exists():
|
||||
request_repository_update(session, repo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue