mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 22:59:28 +08:00
The queue had no identity of its own: a file picked for one knowledge base could be drained after the screen had moved to another base, another account or no server at all, and a pending picker could resolve into a closed screen. Every task now carries the destination it was picked for (origin, base, account) and the queue carries a generation that is bumped on unmount, sign-out, account switch, base switch and server change. `drain` re-checks both before each file and again after every await, so a retired queue cannot start another request, and a failure or cancellation can no longer be retried into the wrong place. Copies the picker left in the cache are released when they can no longer be used — refused validation, a withdrawn queue, an abandoned screen, a closed screen before the picker resolved. Ownership is decided by the directory, not by the scheme: only paths strictly below `Paths.cache` with no `.`/`..` segment are deleted, and a `content://` URI is never touched, so the learner's own document cannot be destroyed by a cleanup. Both catalogue hooks now key their reload on the server-plus-account identity (`knowledgeScope`) rather than on a client object, so an inline client cannot make them loop while a real switch still clears the previous owner's rows.