Image file not deleted when a doc is removed
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.9.2
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
- add a docx file containing images in a knowledgebase
- remove the above file
- view the folder "image_files" and "upload_files"
✔️ Expected Behavior
Image files in the docx file should be deleted
❌ Actual Behavior
Image files in the docx file not deleted
The issue you're experiencing, where image files are not deleted when a document is removed, might be related to the cleanup process not being triggered or executed correctly. The function responsible for cleaning up associated files when a document is deleted is clean_notion_document_task. This function is supposed to handle the removal of document segments from the database and delete associated files from storage [1][2][3].
Here are a few things you might want to check or try:
-
Ensure Event Triggering: Verify that the
document_was_deletedevent is being triggered correctly when you delete a document. This event should initiate the cleanup process. -
Check for Errors: Look for any error logs or exceptions that might be occurring during the deletion process. The code includes exception handling that logs errors if the cleanup fails [4].
-
Review Configuration: Although I couldn't find specific configuration settings or flags that control the deletion of image files, ensure that your setup is correctly configured to allow file deletions.
If these steps don't resolve the issue, it might require a deeper investigation into the code or configuration of your Dify instance.
To continue talking to Dosu, mention @dosu.
You need to run clean_notion_document_task to clean up things there. If you are using source code, please make sure you ran this command mannually.
@crazywoola We're uploading documents from local disk instead of Notion. When deleting a doc in the web, the doc in "uplaod_files" folder is deleted, but image files extrating from the doc remains in "image_files" folder. Please reopen this issue.