X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/cec8f61ab84122a3f4b0702aaad6f7a141f99f7b..cdaa5e28290fe0e9e73ca3a0557ee021a7ab404b:/src/Phorkie/Repository.php diff --git a/src/Phorkie/Repository.php b/src/Phorkie/Repository.php index 5273b60..bcaf3e1 100644 --- a/src/Phorkie/Repository.php +++ b/src/Phorkie/Repository.php @@ -76,7 +76,7 @@ class Repository return $arFiles; } - public function getFileByName($name) + public function getFileByName($name, $bHasToExist = true) { $base = basename($name); if ($base != $name) { @@ -86,7 +86,7 @@ class Repository throw new Exception_Input('Empty file name given'); } $path = $this->repoDir . '/' . $base; - if (!is_readable($path)) { + if ($bHasToExist && !is_readable($path)) { throw new Exception_Input('File does not exist'); } return new File($path, $this); @@ -102,6 +102,17 @@ class Repository return true; } + /** + * Permanently deletes the paste repository without any way to get + * it back. + * + * @return boolean True if all went well, false if not + */ + public function delete() + { + return Tools::recursiveDelete($this->repoDir); + } + public function getDescription() { if (!is_readable($this->repoDir . '/.git/description')) { @@ -133,8 +144,12 @@ class Repository return '/' . $this->id; } else if ($type == 'fork') { return '/' . $this->id . '/fork'; + } else if ($type == 'delete') { + return '/' . $this->id . '/delete'; + } else if ($type == 'delete-confirm') { + return '/' . $this->id . '/delete/confirm'; } - throw new Exception('Unknown type'); + throw new Exception('Unknown link type'); } }