handle undefined local clone urls
[phorkie.git] / src / phorkie / Repository / Post.php
index 0860cad631b665fb50f047fab80a35163a790760..c9f6a537ae1016698770382f25cd038f03db445e 100644 (file)
@@ -116,6 +116,10 @@ class Repository_Post
                     && $file->getContent() != $arFile['content']
                 )
             ) {
+                $dir = dirname($file->getFullPath());
+                if (!is_dir($dir)) {
+                    mkdir($dir, 0777, true);
+                }
                 file_put_contents($file->getFullPath(), $arFile['content']);
                 $command = $vc->getCommand('add')
                     ->addArgument($file->getFilename())
@@ -178,7 +182,15 @@ class Repository_Post
             if ($_FILES['files']['error'][$num]['upload'] == 0) {
                 return true;
             }
-            if ($arFile['content'] != '') {
+            if (isset($arFile['content']) && $arFile['content'] != '') {
+                return true;
+            }
+            if (isset($arFile['name']) && $arFile['name'] != '') {
+                //binary files do not have content
+                return true;
+            }
+            if (isset($arFile['delete']) && $arFile['delete'] != '') {
+                //binary files do not have content
                 return true;
             }
         }
@@ -216,7 +228,7 @@ class Repository_Post
         return $prefix . $num;
     }
 
-    protected function getType($content)
+    public function getType($content)
     {
         $tmp = tempnam(sys_get_temp_dir(), 'phorkie-autodetect-');
         file_put_contents($tmp, $content);