From 6e819603af168c7f5ec403b0bffc70948454a329 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Apr 2009 17:18:23 +0000 Subject: Clean up delete code as per Bharat's note --- core/models/item.php | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index 80000afa..b01e9e3d 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -99,35 +99,18 @@ class Item_Model extends ORM_MPTT { parent::delete(); if (is_dir($original_path)) { - if (file_exists($original_path)) { - dir::unlink($original_path); - } + @dir::unlink($original_path); + @dir::unlink(dirname($original_resize_path)); /* - * Both the thumb path and the resize path contain a path to .album.jpg - * So we need to try to delete both the path (may not exist) and its directory. + * The thumb path is a path to .album.jpg not the actual directory. + * So we need to first try to delete the path (may not exist) and then its directory. */ - if (file_exists($original_resize_path)) { - unlink($original_resize_path); - } - if (file_exists(dirname($original_resize_path))) { - dir::unlink(dirname($original_resize_path)); - } - if (file_exists($original_thumb_path)) { - unlink($original_thumb_path); - } - if (file_exists(dirname($original_thumb_path))) { - dir::unlink(dirname($original_thumb_path)); - } + @unlink($original_thumb_path); + @dir::unlink(dirname($original_thumb_path)); } else { - 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); - } + @unlink($original_path); + @unlink($original_resize_path); + @unlink($original_thumb_path); } } -- cgit v1.2.3