Deleting files and corresponding entries from database

后端 未结 5 821
情书的邮戳
情书的邮戳 2021-01-25 19:08

I have a web site which handles files management. User can upload file, add description, edit and delete. What are the best practices for that kind of scenario?

  1. <
5条回答
  •  遇见更好的自我
    2021-01-25 19:37

    I would personally make sure the database gets the priority as it is more fundamental to the system. So i'd make sure the db row gets deleted, then delete the file. If the file deletion fails, i'd make it fail silently. I would then have a cronjob checking against all files if they have their db counterpart, and if not, marked them for deletion, so the system stays clean and coherent.

提交回复
热议问题