summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-07 16:50:07 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-07 16:50:07 +0100
commit7dd18741887ef40fd7b15b6a71cf882897b5fd61 (patch)
treee0a00589aea7240ac9a1d39509dacf8d3b2936e8 /apps/files_external/lib
parente4c5bf790d670eceac01f2e8c7750182b17123f3 (diff)
parent35ab7f0e64316eba1966bde406f31885b61f15a8 (diff)
downloadnextcloud-server-7dd18741887ef40fd7b15b6a71cf882897b5fd61.tar.gz
nextcloud-server-7dd18741887ef40fd7b15b6a71cf882897b5fd61.zip
Merge pull request #20980 from owncloud/UoM-ResPlat-DevOps-swift-improved-fopen
Improving fopen behaviour for Swift backend
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/swift.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index e946e7feb77..a64a02a4ed9 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -354,9 +354,18 @@ class Swift extends \OC\Files\Storage\Common {
}
$tmpFile = \OCP\Files::tmpFile($ext);
\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');
file_put_contents($tmpFile, $source);
+ // Seek to end if required
+ if ($mode[0] === 'a') {
+ fseek($tmpFile, 0, SEEK_END);
+ }
}
self::$tmpFiles[$tmpFile] = $path;