diff options
Diffstat (limited to 'apps/files_external/lib/Lib/Storage/Swift.php')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/Swift.php | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index ba0b4898e2e..5fec278ef3d 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -37,6 +37,7 @@ namespace OCA\Files_External\Lib\Storage; use Guzzle\Http\Url; use Guzzle\Http\Exception\ClientErrorResponseException; +use Icewind\Streams\CallbackWrapper; use Icewind\Streams\IteratorDirectory; use OpenCloud; use OpenCloud\Common\Exceptions; @@ -410,7 +411,6 @@ class Swift extends \OC\Files\Storage\Common { $ext = ''; } $tmpFile = \OCP\Files::tmpFile($ext); - \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); // Fetch existing file if required if ($mode[0] !== 'w' && $this->file_exists($path)) { if ($mode[0] === 'x') { @@ -424,9 +424,10 @@ class Swift extends \OC\Files\Storage\Common { fseek($tmpFile, 0, SEEK_END); } } - self::$tmpFiles[$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); + }); } } @@ -615,12 +616,9 @@ class Swift extends \OC\Files\Storage\Common { return $this->container; } - public function writeBack($tmpFile) { - if (!isset(self::$tmpFiles[$tmpFile])) { - return false; - } + public function writeBack($tmpFile, $path) { $fileData = fopen($tmpFile, 'r'); - $this->getContainer()->uploadObject(self::$tmpFiles[$tmpFile], $fileData); + $this->getContainer()->uploadObject($path, $fileData); // invalidate target object to force repopulation on fetch $this->objectCache->remove(self::$tmpFiles[$tmpFile]); unlink($tmpFile); |