X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/9e9f228abdf3f10d369b2699ffef29b59ff2bbf4..b7064cd463c2f90cd30f25add6456ea23572661a:/src/phorkie/Repository/Post.php diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index 828dbad..b9d9be5 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -44,13 +44,20 @@ class Repository_Post } $bNew = false; + $bDelete = false; if (!isset($orignalName) || $orignalName == '') { //new file $bNew = true; + if (strpos($name, '.') === false) { + //automatically append file extension if none is there + $name .= '.' . $arFile['type']; + } } else if (!$this->repo->hasFile($orignalName)) { //unknown file //FIXME: Show error message continue; + } else if (isset($arFile['delete']) && $arFile['delete'] == 1) { + $bDelete = true; } else if ($orignalName != $name) { //FIXME: what to do with overwrites? $vc->getCommand('mv') @@ -61,7 +68,12 @@ class Repository_Post } $file = $this->repo->getFileByName($name, false); - if ($bNew || $file->getContent() != $arFile['content']) { + if ($bDelete) { + $command = $vc->getCommand('rm') + ->addArgument($file->getFilename()) + ->execute(); + $bChanged = true; + } else if ($bNew || $file->getContent() != $arFile['content']) { file_put_contents($file->getPath(), $arFile['content']); $command = $vc->getCommand('add') ->addArgument($file->getFilename())