summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-03-18 22:42:31 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-03-18 22:42:31 +0000
commitccb02b001f96f743e73a1b4a31b5e7053814c642 (patch)
treed3be1f9e360eb02450f0d05f7722c1a1ba050716 /core
parent6b5d395d593fb9887cd15e37a0c10ee8334935b6 (diff)
Fix for ticket #155. Delete the item record before unlinking the
files.
Diffstat (limited to 'core')
-rw-r--r--core/models/item.php20
1 files changed, 13 insertions, 7 deletions
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();
}
/**