Link a Download to its domain by its destination column

`domain_download_links` read the destination only from a Download's settings, but the destination is now a column
(the config import moves an old settings destination into it), so no Download was linked to a domain by its
directory.  Read the column, and the settings for an old Download, as channels already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-10-25 16:35:54 -06:00
parent 79526afebe
commit 76105baf9b
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 29 additions and 3 deletions

View file

@ -1018,10 +1018,12 @@ def domain_download_links(session: Session) -> Dict[int, int]:
links = dict()
downloads = session.query(Download.id, Download.url, Download.downloader, Download.sub_downloader,
Download.settings) \
Download.destination, Download.settings) \
.filter(Download.frequency.isnot(None), Download.collection_id.is_(None))
for id_, url, downloader, sub_downloader, settings in downloads:
if destination := (settings or dict()).get('destination'):
for id_, url, downloader, sub_downloader, destination, settings in downloads:
# An old Download kept its destination in its settings.
destination = str(destination) if destination else (settings or dict()).get('destination')
if destination:
for collection_id, directory, prefix in directories:
if destination == directory or destination.startswith(prefix):
links[id_] = collection_id