diff options
-rw-r--r-- | core/libraries/ORM_MPTT.php | 15 | ||||
-rw-r--r-- | core/models/item.php | 28 |
2 files changed, 14 insertions, 29 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index 61c67b99..411afe44 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -229,10 +229,9 @@ class ORM_MPTT_Core extends ORM { * * @chainable * @param Item_Model $target Target item (must be an album) - * @param boolean $locked The caller is already holding the lock * @return ORM_MTPP */ - function move_to($target, $locked=false) { + function move_to($target) { if ($target->type != "album") { throw new Exception("@todo INVALID_MOVE_TYPE $target->type"); } @@ -248,9 +247,7 @@ class ORM_MPTT_Core extends ORM { $original_right = $this->right; $target_right = $target->right; - if (empty($locked)) { - $this->lock(); - } + $this->lock(); try { // Make a hole in the target for the move $target->db->query( @@ -290,15 +287,11 @@ class ORM_MPTT_Core extends ORM { " WHERE `right` > $right"); } catch (Exception $e) { - if (empty($locked)) { - $this->unlock(); - } + $this->unlock(); throw $e; } - if (empty($locked)) { - $this->_unlock(); - } + $this->unlock(); // Lets reload to get the changes. $this->reload(); diff --git a/core/models/item.php b/core/models/item.php index bb0adc5a..866315f7 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -60,28 +60,20 @@ class Item_Model extends ORM_MPTT { * @return ORM_MTPP */ function move_to($target) { - $this->lock(); - try { - $original_path = $this->file_path(); - $original_resize_path = $this->resize_path(); - $original_thumbnail_path = $this->thumbnail_path(); + $original_path = $this->file_path(); + $original_resize_path = $this->resize_path(); + $original_thumbnail_path = $this->thumbnail_path(); - parent::move_to($target, true); + parent::move_to($target, true); - rename($original_path, $this->file_path()); - if (file_exists($original_resize_path)) { - rename($original_resize_path, $this->resize_path()); - } - if (file_exists($original_thumbnail_path)) { - rename($original_thumbnail_path, $this->thumbnail_path()); - } - - } catch (Exception $e) { - $this->unlock(); - throw $e; + rename($original_path, $this->file_path()); + if (file_exists($original_resize_path)) { + rename($original_resize_path, $this->resize_path()); + } + if (file_exists($original_thumbnail_path)) { + rename($original_thumbnail_path, $this->thumbnail_path()); } - $this->unlock(); return $this; } |