fix: claim_ownerless actually claims ownerless documents (was a no-op self-update) (#1288)

This commit is contained in:
Afonso Coutinho 2026-06-02 17:38:38 +01:00 committed by GitHub
parent c39d8db12a
commit 8852c7ea4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,10 +58,12 @@ def main():
count = db.query(Session).filter(Session.owner == None).update({"owner": owner})
print(f" sessions: claimed {count}")
# Documents
count = db.query(Document).filter(Document.session_id.in_(
db.query(Session.id).filter(Session.owner == owner)
)).update({"session_id": Document.session_id}, synchronize_session=False)
# Documents (have their own owner column; claim the ownerless ones,
# mirroring the sessions/gallery/comparisons blocks). The old query set
# session_id to itself — a no-op — and never set owner, so ownerless
# documents stayed ownerless and invisible in the user's Library.
count = db.query(Document).filter(Document.owner == None).update({"owner": owner})
print(f" documents: claimed {count}")
# Gallery
if GalleryImage: