summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/helpers/movie.php3
-rw-r--r--core/helpers/photo.php11
-rw-r--r--core/models/item.php11
3 files changed, 21 insertions, 4 deletions
diff --git a/core/helpers/movie.php b/core/helpers/movie.php
index 658bc185..7ec4c2e0 100644
--- a/core/helpers/movie.php
+++ b/core/helpers/movie.php
@@ -79,7 +79,8 @@ class movie_Core {
$movie->add_to_parent($parent);
// If the thumb or resize already exists then rename it
- if (file_exists($movie->resize_path()) || file_exists($movie->thumb_path())) {
+ if (file_exists($movie->resize_path()) ||
+ file_exists($movie->thumb_path())) {
$movie->name = $pi["filename"] . "-" . rand() . "." . $pi["extension"];
$movie->save();
}
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index a3f88ecb..a6934286 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -74,11 +74,17 @@ class photo_Core {
// @todo Improve this. Random numbers are not user friendly
$photo->name = rand() . "." . $pi["extension"];
}
+
// This saves the photo
$photo->add_to_parent($parent);
- // If the thumb or resize already exists then rename it
- if (file_exists($photo->resize_path()) || file_exists($photo->thumb_path())) {
+ /*
+ * If the thumb or resize already exists then rename it. We need to do this after the save
+ * because the resize_path and thumb_path both call relative_path which caches the
+ * path. Before add_to_parent the relative path will be incorrect.
+ */
+ if (file_exists($photo->resize_path()) ||
+ file_exists($photo->thumb_path())) {
$photo->name = $pi["filename"] . "-" . rand() . "." . $pi["extension"];
$photo->save();
}
@@ -91,7 +97,6 @@ class photo_Core {
graphics::generate($photo);
// If the parent has no cover item, make this it.
- $parent = $photo->parent();
if ($parent->album_cover_item_id == null) {
$parent->album_cover_item_id = $photo->id;
$parent->save();
diff --git a/core/models/item.php b/core/models/item.php
index b28f71fe..156080c2 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -288,6 +288,17 @@ class Item_Model extends ORM_MPTT {
}
/**
+ * @see ORM::__set()
+ */
+ public function __set($column, $value) {
+ if ($column == "name") {
+ // Clear the relative path as it is no longer valid.
+ $this->relative_path = null;
+ }
+ parent::__set($column, $value);
+ }
+
+ /**
* @see ORM::save()
*/
public function save() {