summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/item.php')
-rw-r--r--modules/gallery/helpers/item.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 6a740de4..0710d8b2 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -43,6 +43,17 @@ class item_Core {
// Moving may result in name or slug conflicts. If that happens, try up to 5 times to pick a
// random name (or slug) to avoid the conflict.
+ $message = item::save_with_retries($source);
+
+ // If the target has no cover item, make this it.
+ if ($target->album_cover_item_id == null) {
+ item::make_album_cover($source);
+ }
+
+ return $message;
+ }
+
+ static function save_with_retries($source, $retries=5) {
$orig_name = $source->name;
$orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
$orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
@@ -91,12 +102,6 @@ class item_Core {
}
}
}
-
- // If the target has no cover item, make this it.
- if ($target->album_cover_item_id == null) {
- item::make_album_cover($source);
- }
-
return $message;
}