summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTigran Mkrtchyan <tigran.mkrtchyan@desy.de>2020-12-07 18:24:37 +0100
committerTigran Mkrtchyan <tigran.mkrtchyan@desy.de>2022-08-25 11:11:49 +0200
commitb6065a236fe470e37b28e768d9e09b25e92b470d (patch)
tree90895380a119406a658992b0e984b7e40be4c66f /lib
parent9b5569ff74bbc099af7c2010471bae8958aa9dd4 (diff)
downloadnextcloud-server-b6065a236fe470e37b28e768d9e09b25e92b470d.tar.gz
nextcloud-server-b6065a236fe470e37b28e768d9e09b25e92b470d.zip
files: make OC\Files\Storage\Local WORM friendly
Some filesystems run as a Write-Once-Read-Many storages. This makes them impossible to use with NexeCloud, as the file system layers uses `truncate` syscall (through file_put_contents function). As Nextcloud is never updates existing files, removing the old entry and creatint a new one on update will allow NextCoud to update on such file systems. Update Local#fopen and Local#file_put_contents to remote existing file before truncating. Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Local.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 4996572a40e..7af512ca3f6 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -297,6 +297,8 @@ class Local extends \OC\Files\Storage\Common {
public function file_put_contents($path, $data) {
$oldMask = umask($this->defUMask);
+ // support Write-Once-Read-Many filesystems
+ $this->unlink($path);
$result = file_put_contents($this->getSourcePath($path), $data);
umask($oldMask);
return $result;
@@ -378,6 +380,10 @@ class Local extends \OC\Files\Storage\Common {
public function fopen($path, $mode) {
$oldMask = umask($this->defUMask);
+ if ($mode === 'w') {
+ // support Write-Once-Read-Many filesystems
+ $this->unlink($path);
+ }
$result = fopen($this->getSourcePath($path), $mode);
umask($oldMask);
return $result;