summaryrefslogtreecommitdiffstats
path: root/lib/private/Archive
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-01-03 17:26:44 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-01-06 15:33:32 +0100
commit5774d3e82c093166e21ebb1d469e85acd240dab8 (patch)
tree909001d4ad898f1c4ccab05333f4dd52e8d71b37 /lib/private/Archive
parent3ab22c2df53c8b86cbd72037ab407327b18cce11 (diff)
downloadnextcloud-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.php19
-rw-r--r--lib/private/Archive/ZIP.php18
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);
}
/**