summaryrefslogtreecommitdiff
path: root/modules/gallery/models
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-10-24 10:08:48 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-10-24 10:08:48 -0700
commit607662d66be4361c20322c7db84f9e7b1c529ba2 (patch)
tree1617cd5ed7eff51f81435e94f202aafa231279a4 /modules/gallery/models
parent571d7fe43c4987d75924e1185b5d9ebe0034acd4 (diff)
When an item is renamed or move insure that the target file name doesn't exist. fixes ticket #694
Diffstat (limited to 'modules/gallery/models')
-rw-r--r--modules/gallery/models/item.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 6f0e3525..c210fb54 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -99,6 +99,10 @@ class Item_Model extends ORM_MPTT {
throw new Exception("@todo INVALID_MOVE_TYPE $target->type");
}
+ if (file_exists($target_file = "{$target->file_path()}/$this->name")) {
+ throw new Exception("@todo INVALID_MOVE_TARGET_EXISTS: $target_file");
+ }
+
if ($this->id == 1) {
throw new Exception("@todo INVALID_SOURCE root album");
}
@@ -147,6 +151,10 @@ class Item_Model extends ORM_MPTT {
$old_relative_path = urldecode($this->relative_path());
$new_relative_path = dirname($old_relative_path) . "/" . $new_name;
+ if (file_exists(VARPATH . "albums/$new_relative_path")) {
+ throw new Exception("@todo INVALID_RENAME_FILE_EXISTS: $new_relative_path");
+ }
+
@rename(VARPATH . "albums/$old_relative_path", VARPATH . "albums/$new_relative_path");
@rename(VARPATH . "resizes/$old_relative_path", VARPATH . "resizes/$new_relative_path");
@rename(VARPATH . "thumbs/$old_relative_path", VARPATH . "thumbs/$new_relative_path");