Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: clean up vector data and files when deleting a knowledge directory - #29656

Open
Classic298 wants to merge 1 commit into
open-webui:devfrom
Classic298:knowledge-dir-delete-cleanup
Open

fix: clean up vector data and files when deleting a knowledge directory#29656
Classic298 wants to merge 1 commit into
open-webui:devfrom
Classic298:knowledge-dir-delete-cleanup

Conversation

@Classic298

@Classic298 Classic298 commented Sep 4, 2026

Copy link
Copy Markdown
Member

Deleting a directory in a knowledge base with "Delete all contents inside this directory" took the contained files out of the knowledge base but left their embeddings in the knowledge collection. The deleted content was still retrieved into answers, and uploading the same content again was rejected as duplicate content, permanently.

Every other removal path already purges those chunks. The directory path now does the same: the files in the deleted subtree are collected before their links are dropped, and their chunks are removed by file id and by hash regardless of ENABLE_KNOWLEDGE_FILE_RETENTION. The file record, the stored copy and the per-file collection are removed only when retention is disabled, the file is no longer referenced by any knowledge base and the actor owns it or is an admin, which is what removing a file individually does.

The lookup is scoped to the knowledge base from the request, so a directory nested under a different knowledge base's directory no longer has its file's chunks deleted from the wrong collection.

Fixes #29636

Contributor License Agreement

Deleting a directory in a knowledge base with "Delete all contents inside this directory" took the contained files out of the knowledge base but left their embeddings in the knowledge collection. The deleted content was still retrieved into answers, and uploading the same content again was rejected as duplicate content, permanently.

Every other removal path already purges those chunks. The directory path now does the same: the files in the deleted subtree are collected before their links are dropped, and their chunks are removed by file id and by hash regardless of ENABLE_KNOWLEDGE_FILE_RETENTION. The file record, the stored copy and the per-file collection are removed only when retention is disabled, the file is no longer referenced by any knowledge base and the actor owns it or is an admin, which is what removing a file individually does.

The lookup is scoped to the knowledge base from the request, so a directory nested under a different knowledge base's directory no longer has its file's chunks deleted from the wrong collection.

Fixes open-webui#29636
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant