From ccb02b001f96f743e73a1b4a31b5e7053814c642 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 18 Mar 2009 22:42:31 +0000 Subject: Fix for ticket #155. Delete the item record before unlinking the files. --- core/models/item.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index 0ca40503..1aa9a9be 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -98,18 +98,24 @@ class Item_Model extends ORM_MPTT { $original_thumb_path = $this->thumb_path(); // If there is no name, the path is invalid so don't try to delete + parent::delete(); if (!empty($this->name)) { if ($this->is_album()) { - dir::unlink($original_path); - dir::unlink($original_resize_path); - dir::unlink($original_thumb_path); + @dir::unlink($original_path); + @dir::unlink($original_resize_path); + @dir::unlink($original_thumb_path); } else { - unlink($original_path); - unlink($original_resize_path); - unlink($original_thumb_path); + if (file_exists($original_path)) { + @unlink($original_path); + } + if (file_exists($original_resize_path)) { + @unlink($original_resize_path); + } + if (file_exists($original_thumb_path)) { + @unlink($original_thumb_path); + } } } - parent::delete(); } /** -- cgit v1.2.3