summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-12 23:22:05 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-12 23:22:05 +0000
commit2b798193231d27f517aeb8c37a854c6787d65fab (patch)
treef49fd94fb1bfbc7e1cc12cfe40e5b61a28691fd8 /core
parentd05e7a05e9d1a785856503ddee8b98649e38a539 (diff)
Simplify delete()
Diffstat (limited to 'core')
-rw-r--r--core/models/item.php24
1 files changed, 10 insertions, 14 deletions
diff --git a/core/models/item.php b/core/models/item.php
index ea9196d5..d49f748a 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -97,27 +97,23 @@ class Item_Model extends ORM_MPTT {
module::event("item_before_delete", $this);
$parent = $this->parent();
-
if ($parent->album_cover_item_id == $this->id) {
item::remove_album_cover($parent);
}
- $original_path = $this->file_path();
- $original_resize_path = $this->resize_path();
- $original_thumb_path = $this->thumb_path();
+ $path = $this->file_path();
+ $resize_path = $this->resize_path();
+ $thumb_path = $this->thumb_path();
parent::delete();
- if (is_dir($original_path)) {
- @dir::unlink($original_path);
- @dir::unlink(dirname($original_resize_path));
- // 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.
- @unlink($original_thumb_path);
- @dir::unlink(dirname($original_thumb_path));
+ if (is_dir($path)) {
+ @dir::unlink($path);
+ @dir::unlink(dirname($resize_path));
+ @dir::unlink(dirname($thumb_path));
} else {
- @unlink($original_path);
- @unlink($original_resize_path);
- @unlink($original_thumb_path);
+ @unlink($path);
+ @unlink($resize_path);
+ @unlink($thumb_path);
}
}