diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-11 15:28:35 +0300 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-11-11 15:28:35 +0300 |
commit | a2fdd6f2e4f515abf6c38a913b4c96b2a67cb850 (patch) | |
tree | 54c1050011d53009ea2865e7cb72dce252fc73b1 /lib | |
parent | 68aa221229050419fed3ff995365fa3fd2b479a1 (diff) |
Allow file operations on part files on perm masked storage (#26606)
When uploading a file to a storage that has reduced permissions, we
still need to be able to create or rename the part files to the final
file. This fix makes that rename possible.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Storage/Wrapper/PermissionsMask.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php index 466b0a80e1c..af18e08d629 100644 --- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php @@ -76,8 +76,13 @@ class PermissionsMask extends Wrapper { return $this->storage->getPermissions($path) & $this->mask; } + private function isPartFile($path) { + return pathinfo($path, PATHINFO_EXTENSION) === 'part'; + } + public function rename($path1, $path2) { - return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($path1, $path2); + // allow renaming part files + return ($this->isPartFile($path1) || $this->checkMask(Constants::PERMISSION_UPDATE)) && parent::rename($path1, $path2); } public function copy($path1, $path2) { @@ -86,7 +91,7 @@ class PermissionsMask extends Wrapper { public function touch($path, $mtime = null) { $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; - return $this->checkMask($permissions) and parent::touch($path, $mtime); + return ($this->isPartFile($path) || $this->checkMask($permissions)) && parent::touch($path, $mtime); } public function mkdir($path) { @@ -103,7 +108,7 @@ class PermissionsMask extends Wrapper { public function file_put_contents($path, $data) { $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; - return $this->checkMask($permissions) and parent::file_put_contents($path, $data); + return ($this->isPartFile($path) || $this->checkMask($permissions)) && parent::file_put_contents($path, $data); } public function fopen($path, $mode) { @@ -111,7 +116,7 @@ class PermissionsMask extends Wrapper { return parent::fopen($path, $mode); } else { $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; - return $this->checkMask($permissions) ? parent::fopen($path, $mode) : false; + return ($this->isPartFile($path) || $this->checkMask($permissions)) ? parent::fopen($path, $mode) : false; } } |