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/Files/Storage/DAV.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/Files/Storage/DAV.php')
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index ea4bbba2748..62906f9355b 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -36,6 +36,7 @@ namespace OC\Files\Storage; use Exception; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Message\ResponseInterface; +use Icewind\Streams\CallbackWrapper; use OC\Files\Filesystem; use OC\Files\Stream\Close; use Icewind\Streams\IteratorDirectory; @@ -77,8 +78,6 @@ class DAV extends Common { private $client; /** @var ArrayCache */ private $statCache; - /** @var array */ - private static $tempFiles = []; /** @var \OCP\Http\Client\IClientService */ private $httpClientService; @@ -409,20 +408,19 @@ class DAV extends Common { } $tmpFile = $tempManager->getTemporaryFile($ext); } - 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); + }); } } /** * @param string $tmpFile */ - public function writeBack($tmpFile) { - if (isset(self::$tempFiles[$tmpFile])) { - $this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]); - unlink($tmpFile); - } + public function writeBack($tmpFile, $path) { + $this->uploadFile($tmpFile, $path); + unlink($tmpFile); } /** {@inheritdoc} */ |