diff options
author | Robin Appelman <robin@icewind.nl> | 2017-01-03 17:26:44 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-01-06 15:33:32 +0100 |
commit | 5774d3e82c093166e21ebb1d469e85acd240dab8 (patch) | |
tree | 909001d4ad898f1c4ccab05333f4dd52e8d71b37 /lib/private/Archive/TAR.php | |
parent | 3ab22c2df53c8b86cbd72037ab407327b18cce11 (diff) | |
download | nextcloud-server-5774d3e82c093166e21ebb1d469e85acd240dab8.tar.gz nextcloud-server-5774d3e82c093166e21ebb1d469e85acd240dab8.zip |
replace close:// streamwrapper with CallBackWrapper
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Archive/TAR.php')
-rw-r--r-- | lib/private/Archive/TAR.php | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php index bbd24bd05a1..07ccd09f399 100644 --- a/lib/private/Archive/TAR.php +++ b/lib/private/Archive/TAR.php @@ -33,6 +33,8 @@ namespace OC\Archive; +use Icewind\Streams\CallbackWrapper; + class TAR extends Archive { const PLAIN = 0; const GZIP = 1; @@ -359,22 +361,19 @@ class TAR extends Archive { if ($mode == 'r' or $mode == 'rb') { return fopen($tmpFile, $mode); } else { - \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); - self::$tempFiles[$tmpFile] = $path; - return fopen('close://' . $tmpFile, $mode); + $handle = fopen($tmpFile, $mode); + return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { + $this->writeBack($tmpFile, $path); + }); } } - private static $tempFiles = array(); - /** * write back temporary files */ - function writeBack($tmpFile) { - if (isset(self::$tempFiles[$tmpFile])) { - $this->addFile(self::$tempFiles[$tmpFile], $tmpFile); - unlink($tmpFile); - } + function writeBack($tmpFile, $path) { + $this->addFile($path, $tmpFile); + unlink($tmpFile); } /** |