dify icon indicating copy to clipboard operation
dify copied to clipboard

Image file not deleted when a doc is removed

Open wy96f opened this issue 2 years ago • 3 comments

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

  1. add a docx file containing images in a knowledgebase
  2. remove the above file
  3. 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

wy96f avatar Oct 21 '24 07:10 wy96f

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:

  1. Ensure Event Triggering: Verify that the document_was_deleted event is being triggered correctly when you delete a document. This event should initiate the cleanup process.

  2. 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].

  3. 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.

dosubot[bot] avatar Oct 21 '24 07:10 dosubot[bot]

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 avatar Oct 21 '24 07:10 crazywoola

@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.

wy96f avatar Oct 21 '24 09:10 wy96f