[PR #8547] [MERGED] fix: File deletion doesn't properly clean up database entries #9038

Closed
opened 2025-11-11 18:12:23 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/8547
Author: @juananpe
Created: 1/14/2025
Status: Merged
Merged: 1/15/2025
Merged by: @tjbck

Base: devHead: file-deletion


📝 Commits (1)

📊 Changes

5 files changed (+34 additions, -15 deletions)

View changed files

📝 backend/open_webui/routers/files.py (+2 -0)
📝 src/lib/components/chat/MessageInput.svelte (+14 -3)
📝 src/lib/components/common/FileItem.svelte (+2 -0)
📝 src/lib/components/workspace/Knowledge/KnowledgeBase.svelte (+15 -11)
📝 src/lib/components/workspace/Knowledge/KnowledgeBase/Files.svelte (+1 -1)

📄 Description

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 following the format
  • Code review: Have you performed a self-review of your code

Changelog Entry

Fix file deletion to properly clean up resources

Description

When deleting files from either knowledge bases or chat, the system wasn't properly cleaning up all associated resources, particularly in the sqlite DB. This caused issues with re-uploading previously deleted files and left orphaned entries in the database and the uploads/ folder.

Known issues

  • There still are orphaned collections (file-UID) in Chroma when removing a file from the chat input. I don't like to add more coupling in routers/files.py with something like this in the delete_file_by_id function:
        file_collection = f"file-{id}"
        if VECTOR_DB_CLIENT.has_collection(collection_name=file_collection):
            VECTOR_DB_CLIENT.delete_collection(collection_name=file_collection)

So I added a comment there ( # We should add Chroma cleanup here) as a placeholder to remember that we should act here.


🔄 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/8547 **Author:** [@juananpe](https://github.com/juananpe) **Created:** 1/14/2025 **Status:** ✅ Merged **Merged:** 1/15/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `file-deletion` --- ### 📝 Commits (1) - [`f477f4f`](https://github.com/open-webui/open-webui/commit/f477f4f79015788a8f96d56ff365a900d7e902fb) fix: fixess issue #7181 ### 📊 Changes **5 files changed** (+34 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/files.py` (+2 -0) 📝 `src/lib/components/chat/MessageInput.svelte` (+14 -3) 📝 `src/lib/components/common/FileItem.svelte` (+2 -0) 📝 `src/lib/components/workspace/Knowledge/KnowledgeBase.svelte` (+15 -11) 📝 `src/lib/components/workspace/Knowledge/KnowledgeBase/Files.svelte` (+1 -1) </details> ### 📄 Description # 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 following the format - [x] **Code review:** Have you performed a self-review of your code # Changelog Entry Fix file deletion to properly clean up resources ### Description When deleting files from either knowledge bases or chat, the system wasn't properly cleaning up all associated resources, particularly in the sqlite DB. This caused issues with re-uploading previously deleted files and left orphaned entries in the database and the uploads/ folder. ### Known issues - There still are orphaned collections (file-UID) in Chroma when removing a file from the chat input. I don't like to add more coupling in routers/files.py with something like this in the `delete_file_by_id` function: ```python file_collection = f"file-{id}" if VECTOR_DB_CLIENT.has_collection(collection_name=file_collection): VECTOR_DB_CLIENT.delete_collection(collection_name=file_collection) ``` So I added a comment there ( # We should add Chroma cleanup here) as a placeholder to remember that we should act here. --- <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 2025-11-11 18:12:23 -06: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#9038