Suggestion Move Posts and Pages Deleted

Topics: Business Logic Layer
Aug 14, 2008 at 2:11 PM

After experiencing some user quisiness over the deletion of some posts and pages that weren't what was intended, I had a suggestion on making Page and Post Delete methods to move to a "deleted" directory instead of removing the file.

There are two other nagging concerns on deletes.

  1. What happens to images that are "only" used in this post / page - should those get cleaned up or just left lying around?
  2. What happens to data created / used by "extensions" like the Most Popular Post Extension on deletes.  I've had circumstances where a post deleted, was in the most popular post list, but when it was deleted, it caused exceptions.  I had to manually clean up the counter.  Should there be a post deleted event that fires so extensions can clean up whatever data they create?

Example code changed to move instead of delete:

File: BlogEngine.Core\Providers\XmlProvider\Posts.cs
public override void DeletePost(Post post)
{
string fileName = _Folder + "posts" + Path.DirectorySeparatorChar + post.Id.ToString() + ".xml";
string fileNameDeleted = _Folder + "posts" + Path.DirectorySeparatorChar + "deleted" + Path.DirectorySeparatorChar + post.Id.ToString() + ".xml";
string pathDeleted = _Folder + "posts" + Path.DirectorySeparatorChar + "deleted";
if (File.Exists(fileName))
{
//File.Delete(fileName);
if (Directory.Exists(pathDeleted))
{
File.Move(fileName, fileNameDeleted);
}
else
{
Directory.CreateDirectory(pathDeleted);
}
File.Move(fileName, fileNameDeleted);
}
}