Improving fopen behaviour for Swift backend
This commit is contained in:
parent
884946276e
commit
35ab7f0e64
|
@ -354,9 +354,18 @@ class Swift extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
$tmpFile = \OCP\Files::tmpFile($ext);
|
$tmpFile = \OCP\Files::tmpFile($ext);
|
||||||
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
|
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
|
||||||
if ($this->file_exists($path)) {
|
// Fetch existing file if required
|
||||||
|
if ($mode[0] !== 'w' && $this->file_exists($path)) {
|
||||||
|
if ($mode[0] === 'x') {
|
||||||
|
// File cannot already exist
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$source = $this->fopen($path, 'r');
|
$source = $this->fopen($path, 'r');
|
||||||
file_put_contents($tmpFile, $source);
|
file_put_contents($tmpFile, $source);
|
||||||
|
// Seek to end if required
|
||||||
|
if ($mode[0] === 'a') {
|
||||||
|
fseek($tmpFile, 0, SEEK_END);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self::$tmpFiles[$tmpFile] = $path;
|
self::$tmpFiles[$tmpFile] = $path;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue