|
|
|
|
@ -506,32 +506,27 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil |
|
|
|
|
$urn = $this->getURN($fileId); |
|
|
|
|
try { |
|
|
|
|
//upload to object storage |
|
|
|
|
if ($size === null) { |
|
|
|
|
$countStream = CountWrapper::wrap($stream, function ($writtenSize) use ($fileId, &$size) { |
|
|
|
|
|
|
|
|
|
$totalWritten = 0; |
|
|
|
|
$countStream = CountWrapper::wrap($stream, function ($writtenSize) use ($fileId, $size, $exists, &$totalWritten) { |
|
|
|
|
if (is_null($size) && !$exists) { |
|
|
|
|
$this->getCache()->update($fileId, [ |
|
|
|
|
'size' => $writtenSize, |
|
|
|
|
]); |
|
|
|
|
$size = $writtenSize; |
|
|
|
|
}); |
|
|
|
|
if ($this->objectStore instanceof IObjectStoreMetaData) { |
|
|
|
|
$this->objectStore->writeObjectWithMetaData($urn, $countStream, $metadata); |
|
|
|
|
} else { |
|
|
|
|
$this->objectStore->writeObject($urn, $countStream, $metadata['mimetype']); |
|
|
|
|
} |
|
|
|
|
if (is_resource($countStream)) { |
|
|
|
|
fclose($countStream); |
|
|
|
|
} |
|
|
|
|
$stat['size'] = $size; |
|
|
|
|
$totalWritten = $writtenSize; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if ($this->objectStore instanceof IObjectStoreMetaData) { |
|
|
|
|
$this->objectStore->writeObjectWithMetaData($urn, $countStream, $metadata); |
|
|
|
|
} else { |
|
|
|
|
if ($this->objectStore instanceof IObjectStoreMetaData) { |
|
|
|
|
$this->objectStore->writeObjectWithMetaData($urn, $stream, $metadata); |
|
|
|
|
} else { |
|
|
|
|
$this->objectStore->writeObject($urn, $stream, $metadata['mimetype']); |
|
|
|
|
} |
|
|
|
|
if (is_resource($stream)) { |
|
|
|
|
fclose($stream); |
|
|
|
|
} |
|
|
|
|
$this->objectStore->writeObject($urn, $countStream, $metadata['mimetype']); |
|
|
|
|
} |
|
|
|
|
if (is_resource($countStream)) { |
|
|
|
|
fclose($countStream); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$stat['size'] = $totalWritten; |
|
|
|
|
} catch (\Exception $ex) { |
|
|
|
|
if (!$exists) { |
|
|
|
|
/* |
|
|
|
|
@ -571,7 +566,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $size; |
|
|
|
|
return $totalWritten; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getObjectStore(): IObjectStore { |
|
|
|
|
|