[PR #8499] [MERGED] fix: complete file cleanup when removing from Knowledge Base #45284

Closed
opened 2026-04-29 19:37:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/8499
Author: @juananpe
Created: 1/12/2025
Status: Merged
Merged: 1/13/2025
Merged by: @tjbck

Base: devHead: file-cleanup-knowledge


📝 Commits (1)

  • 913e0d3 fix: complete file cleanup when removing from Knowledge Base

📊 Changes

1 file changed (+13 additions, -1 deletions)

View changed files

📝 backend/open_webui/routers/knowledge.py (+13 -1)

📄 Description

fix: complete file cleanup when removing from Knowledge Base

Pull Request Checklist

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry
  • Prefix: To cleary categorize this pull request, prefix the pull request title

Changelog Entry

  • Fixed file cleanup when removing from Knowledge Base - files are now properly deleted from storage, database, and vector storage instead of remaining as orphaned resources

Description

Currently, when removing a file from a Knowledge Base, the system only partially cleans up the resources. This PR implements a complete cleanup by:

  1. Removing the file's vectors from the Knowledge Base collection in ChromaDB
  2. Removing the file's dedicated collection from ChromaDB (file-{id})
  3. Deleting the physical file from storage
  4. Removing the file entry from the SQLite database
  5. Maintaining the existing security checks and KB data updates

Changed

  • Modified remove_file_from_knowledge_by_id in backend/open_webui/routers/knowledge.py to:
    • Delete the file's vectors from KB collection in ChromaDB
    • Delete the file's dedicated collection from ChromaDB
    • Delete the physical file from storage
    • Remove the file entry from the database
    • Keep existing permission checks and KB data updates

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/8499 **Author:** [@juananpe](https://github.com/juananpe) **Created:** 1/12/2025 **Status:** ✅ Merged **Merged:** 1/13/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `file-cleanup-knowledge` --- ### 📝 Commits (1) - [`913e0d3`](https://github.com/open-webui/open-webui/commit/913e0d391b6d2ec68a055e5d0c787e096ea0d48b) fix: complete file cleanup when removing from Knowledge Base ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/knowledge.py` (+13 -1) </details> ### 📄 Description fix: complete file cleanup when removing from Knowledge Base # Pull Request Checklist - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title # Changelog Entry - Fixed file cleanup when removing from Knowledge Base - files are now properly deleted from storage, database, and vector storage instead of remaining as orphaned resources ### Description Currently, when removing a file from a Knowledge Base, the system only partially cleans up the resources. This PR implements a complete cleanup by: 1. Removing the file's vectors from the Knowledge Base collection in ChromaDB 2. Removing the file's dedicated collection from ChromaDB (file-{id}) 3. Deleting the physical file from storage 4. Removing the file entry from the SQLite database 5. Maintaining the existing security checks and KB data updates ### Changed - Modified `remove_file_from_knowledge_by_id` in `backend/open_webui/routers/knowledge.py` to: - Delete the file's vectors from KB collection in ChromaDB - Delete the file's dedicated collection from ChromaDB - Delete the physical file from storage - Remove the file entry from the database - Keep existing permission checks and KB data updates --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 19:37:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#45284