summaryrefslogtreecommitdiffstats
path: root/lib/private/Archive
diff options
context:
space:
mode:
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);
}
/**