summaryrefslogtreecommitdiff
path: root/lib/plugins/extension/helper/extension.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-08-09 21:34:51 +0200
committerAndreas Gohr <andi@splitbrain.org>2013-08-09 21:34:51 +0200
commit045d57189c1fb4e8775603cd39927557e3eddfd9 (patch)
tree2981f391f596b52c39ab95fc93bec2039a33bd88 /lib/plugins/extension/helper/extension.php
parent5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1 (diff)
downloadrpg-045d57189c1fb4e8775603cd39927557e3eddfd9.tar.gz
rpg-045d57189c1fb4e8775603cd39927557e3eddfd9.tar.bz2
make sure temporary folders are cleaned up
Diffstat (limited to 'lib/plugins/extension/helper/extension.php')
-rw-r--r--lib/plugins/extension/helper/extension.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 8438253f9..dc570aa0d 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -23,6 +23,20 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
/** @var helper_plugin_extension_repository $repository */
private $repository = null;
+ /** @var array list of temporary directories */
+ private $temporary = array();
+
+ /**
+ * Destructor
+ *
+ * deletes any dangling temporary directories
+ */
+ public function __destruct() {
+ foreach($this->temporary as $dir){
+ $this->dir_delete($dir);
+ }
+ }
+
/**
* @return bool false, this component is not a singleton
*/
@@ -698,6 +712,20 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
}
/**
+ * Returns a temporary directory
+ *
+ * The directory is registered for cleanup when the class is destroyed
+ *
+ * @return bool|string
+ */
+ protected function mkTmpDir(){
+ $dir = io_mktmpdir();
+ if(!$dir) return false;
+ $this->temporary[] = $dir;
+ return $dir;
+ }
+
+ /**
* Download an archive to a protected path
*
* @param string $url The url to get the archive from
@@ -713,7 +741,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
$file = $matches[0];
// create tmp directory for download
- if(!($tmp = io_mktmpdir())) {
+ if(!($tmp = $this->mkTmpDir())) {
throw new Exception($this->getLang('error_dircreate'));
}
@@ -736,7 +764,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
public function installArchive($file, $overwrite=false, $base = '') {
// create tmp directory for decompression
- if(!($tmp = io_mktmpdir())) {
+ if(!($tmp = $this->mkTmpDir())) {
throw new Exception($this->getLang('error_dircreate'));
}