deleting files works now
[phorkie.git] / src / phorkie / Repository / Post.php
index 627aa1fae53d83335a713e6281eef48873b743a7..1b6075214e389b9d151a1669d44872baf6f19e22 100644 (file)
@@ -44,6 +44,7 @@ class Repository_Post
             }
 
             $bNew = false;
+            $bDelete = false;
             if (!isset($orignalName) || $orignalName == '') {
                 //new file
                 $bNew = true;
@@ -51,6 +52,8 @@ class Repository_Post
                 //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 +64,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())
@@ -87,9 +95,13 @@ class Repository_Post
         $repo = $rs->createNew();
         $vc = $repo->getVc();
         $vc->initRepository();
+
         foreach (glob($repo->repoDir . '/.git/hooks/*') as $hookfile) {
             unlink($hookfile);
         }
+
+        touch($repo->repoDir . '/.git/git-daemon-export-ok');
+
         return $repo;
     }