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 | |
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')
-rw-r--r-- | lib/private/Archive/TAR.php | 19 | ||||
-rw-r--r-- | lib/private/Archive/ZIP.php | 18 |
2 files changed, 18 insertions, 19 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); } /** diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index 9e9fe40b2b4..0ed0f48acc4 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -31,6 +31,8 @@ namespace OC\Archive; +use Icewind\Streams\CallbackWrapper; + class ZIP extends Archive{ /** * @var \ZipArchive zip @@ -198,24 +200,22 @@ class ZIP extends Archive{ $ext=''; } $tmpFile=\OCP\Files::tmpFile($ext); - \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); if($this->fileExists($path)) { $this->extractFile($path, $tmpFile); } - 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); } /** |