Merge pull request #8711 from nextcloud/objectstore-write-only-fopen
don't read existing file when overwriting using object store
This commit is contained in:
commit
069e3f50a7
|
@ -261,6 +261,12 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
public function fopen($path, $mode) {
|
public function fopen($path, $mode) {
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
|
||||||
|
if (strrpos($path, '.') !== false) {
|
||||||
|
$ext = substr($path, strrpos($path, '.'));
|
||||||
|
} else {
|
||||||
|
$ext = '';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'rb':
|
case 'rb':
|
||||||
|
@ -280,21 +286,21 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'wb':
|
case 'wb':
|
||||||
|
case 'w+':
|
||||||
|
case 'wb+':
|
||||||
|
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||||
|
$handle = fopen($tmpFile, $mode);
|
||||||
|
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
|
||||||
|
$this->writeBack($tmpFile, $path);
|
||||||
|
});
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'ab':
|
case 'ab':
|
||||||
case 'r+':
|
case 'r+':
|
||||||
case 'w+':
|
|
||||||
case 'wb+':
|
|
||||||
case 'a+':
|
case 'a+':
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'x+':
|
case 'x+':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'c+':
|
case 'c+':
|
||||||
if (strrpos($path, '.') !== false) {
|
|
||||||
$ext = substr($path, strrpos($path, '.'));
|
|
||||||
} else {
|
|
||||||
$ext = '';
|
|
||||||
}
|
|
||||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||||
if ($this->file_exists($path)) {
|
if ($this->file_exists($path)) {
|
||||||
$source = $this->fopen($path, 'r');
|
$source = $this->fopen($path, 'r');
|
||||||
|
|
Loading…
Reference in New Issue