Skip to content

Commit

Permalink
files: make OC\Files\Storage\Local WORM friendly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kofemann committed Dec 22, 2020
1 parent 72fda10 commit 75b3261
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 1487 files
6 changes: 6 additions & 0 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public function file_get_contents($path) {
}

public function file_put_contents($path, $data) {
// support Write-Once-Read-Many filesystems
$this->unlink($path);
return file_put_contents($this->getSourcePath($path), $data);
}

Expand Down Expand Up @@ -353,6 +355,10 @@ public function copy($path1, $path2) {
}

public function fopen($path, $mode) {
if ($mode === 'w') {
// support Write-Once-Read-Many filesystems
$this->unlink($path);
}
return fopen($this->getSourcePath($path), $mode);
}

Expand Down

0 comments on commit 75b3261

Please sign in to comment.