summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Parry <github@chad.parry.org>2011-04-23 22:55:59 -0600
committerChad Parry <github@chad.parry.org>2011-04-23 22:55:59 -0600
commitc6ef706d70c7e48bea1145eec1b13fb5683e023f (patch)
tree42587a6c96f0687d123d0894b32d47440bbd3e22
parent0d6a3a3cfc4f38f450db9e18da47a5e2ad826af8 (diff)
Preserve old data files long enough for them to be available to event handlers.
-rw-r--r--modules/gallery/models/item.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 299d3584..482b6247 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -442,7 +442,9 @@ class Item_Model_Core extends ORM_MPTT {
if ($original->parent_id != $this->parent_id || $original->name != $this->name) {
// Move all of the items associated data files
$this->_build_relative_caches();
- @rename($original->file_path(), $this->file_path());
+ if (!isset($this->data_file)) {
+ @rename($original->file_path(), $this->file_path());
+ }
if ($this->is_album()) {
@rename(dirname($original->resize_path()), dirname($this->resize_path()));
@rename(dirname($original->thumb_path()), dirname($this->thumb_path()));
@@ -491,6 +493,9 @@ class Item_Model_Core extends ORM_MPTT {
// Null out the data file variable here, otherwise this event will trigger another
// save() which will think that we're doing another file move.
$this->data_file = null;
+ if ($original->file_path() != $this->file_path()) {
+ @unlink($original->file_path());
+ }
module::event("item_updated_data_file", $this);
}
}