Skip to content

"Safe" file deletion

Roman M. Yagodin edited this page Jan 23, 2020 · 2 revisions

Deleting file safely implies counting file references, which can be stored:

  1. In the DNN content items

  2. In the database table

  3. In the HTML code (links) or elsewhere

Extension which provide safe file deletion (presumably with the corresponding content) will need to:

  • Get DNN content items related to the file

  • Get database records related to the file

  • If file is referenced by any content items or records, which is not about to be deleted right now, the file should not be deleted

  • If file is referenced only by content items or records, which is just about to be deleted, that file can be "safely" deleted

Probably it’s better try to delete content item/database records first, and only after that delete the file.

R7.Dnn.Extensions provide Content/ContentHelper.GetContentItemsByFile for p.1, while concrete extension should be responsible for implementing p.2 and general algorithm.

Implementation of p.3 looks like most problematic - it’s another reason to embrace implementing of DNN ContentItems API across various extensions.

Clone this wiki locally