aboutsummaryrefslogtreecommitdiff
path: root/src/phorkie/Repository/Post.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2015-07-14 07:58:32 +0200
committerChristian Weiske <cweiske@cweiske.de>2015-07-14 07:58:32 +0200
commit808a3a5857c77ef99605fdfdde9b31b5c02e22c6 (patch)
tree87c961fcff7fda8cb3e8fdb80bf3829c10f5df1c /src/phorkie/Repository/Post.php
parenteabef388982e2b198e77f7a7b9e9f5bebfa8d457 (diff)
downloadphorkie-808a3a5857c77ef99605fdfdde9b31b5c02e22c6.tar.gz
phorkie-808a3a5857c77ef99605fdfdde9b31b5c02e22c6.zip
fix crash when renaming file
This bug was introduced by the modified hash handling for caching in 2cd81a7
Diffstat (limited to 'src/phorkie/Repository/Post.php')
-rw-r--r--src/phorkie/Repository/Post.php24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php
index 511a83c..7a373aa 100644
--- a/src/phorkie/Repository/Post.php
+++ b/src/phorkie/Repository/Post.php
@@ -58,8 +58,8 @@ class Repository_Post
continue;
}
- $orignalName = Tools::sanitizeFilename($arFile['original_name']);
- $name = Tools::sanitizeFilename($arFile['name']);
+ $originalName = Tools::sanitizeFilename($arFile['original_name']);
+ $name = Tools::sanitizeFilename($arFile['name']);
if ($arFile['type'] == '_auto_') {
//FIXME: upload
@@ -79,7 +79,7 @@ class Repository_Post
$bNew = false;
$bDelete = false;
- if (!isset($orignalName) || $orignalName == '') {
+ if (!isset($originalName) || $originalName == '') {
//new file
$bNew = true;
if (strpos($name, '.') === false) {
@@ -87,27 +87,30 @@ class Repository_Post
$name .= '.' . $arFile['type'];
}
$this->newfileName = $name;
- } else if (!$this->repo->hasFile($orignalName)) {
+ } else if (!$this->repo->hasFile($originalName)) {
//unknown file
//FIXME: Show error message
continue;
} else if (isset($arFile['delete']) && $arFile['delete'] == 1) {
$bDelete = true;
- } else if ($orignalName != $name) {
+ } else if ($originalName != $name) {
if (strpos($name, '/') === false) {
//ignore names with a slash in it, would be new directory
//FIXME: what to do with overwrites?
$vc->getCommand('mv')
- ->addArgument($orignalName)
+ ->addArgument($originalName)
->addArgument($name)
->execute();
$bCommit = true;
} else {
- $name = $orignalName;
+ $name = $originalName;
}
}
$file = $this->repo->getFileByName($name, false);
+ if ($originalName !== '') {
+ $originalFile = $this->repo->getFileByName($originalName, false);
+ }
if ($bDelete) {
$command = $vc->getCommand('rm')
->addArgument($file->getFilename())
@@ -123,8 +126,8 @@ class Repository_Post
->execute();
$bCommit = true;
} else if ($bNew
- || (isset($arFile['content'])
- && $file->getContent() != $arFile['content']
+ || (isset($arFile['content']) && isset($originalFile)
+ && $originalFile->getContent() != $arFile['content']
)
) {
$dir = dirname($file->getFullPath());
@@ -166,6 +169,9 @@ class Repository_Post
//the post-update hook should do that IMO, but does not somehow
$vc->getCommand('update-server-info')->execute();
+ //we changed the hash by committing, so reload it
+ $this->repo->reloadHash();
+
$bChanged = true;
}