summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/sharedstorage.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/sharedstorage.php')
-rw-r--r--apps/files_sharing/lib/sharedstorage.php60
1 files changed, 40 insertions, 20 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index e5968aeb063..c7285b1d5c6 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -299,26 +299,34 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
// we need the paths relative to data/user/files
$relPath1 = $this->getMountPoint() . '/' . $path1;
$relPath2 = $this->getMountPoint() . '/' . $path2;
-
- // check for update permissions on the share
- if ($this->isUpdatable('')) {
-
- $pathinfo = pathinfo($relPath1);
- // for part files we need to ask for the owner and path from the parent directory because
- // the file cache doesn't return any results for part files
- if (isset($pathinfo['extension']) && $pathinfo['extension'] === 'part') {
- list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($pathinfo['dirname']);
- $path1 = $path1 . '/' . $pathinfo['basename'];
- } else {
- list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($relPath1);
+ $pathinfo = pathinfo($relPath1);
+
+ $isPartFile = (isset($pathinfo['extension']) && $pathinfo['extension'] === 'part');
+ $targetExists = $this->file_exists($path2);
+ $sameFolder = (dirname($relPath1) === dirname($relPath2));
+ if ($targetExists || ($sameFolder && !$isPartFile)) {
+ // note that renaming a share mount point is always allowed
+ if (!$this->isUpdatable('')) {
+ return false;
+ }
+ } else {
+ if (!$this->isCreatable('')) {
+ return false;
}
- $targetFilename = basename($relPath2);
- list($user2, $path2) = \OCA\Files_Sharing\Helper::getUidAndFilename(dirname($relPath2));
- $rootView = new \OC\Files\View('');
- return $rootView->rename('/' . $user1 . '/files/' . $path1, '/' . $user2 . '/files/' . $path2 . '/' . $targetFilename);
}
- return false;
+ // for part files we need to ask for the owner and path from the parent directory because
+ // the file cache doesn't return any results for part files
+ if ($isPartFile) {
+ list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($pathinfo['dirname']);
+ $path1 = $path1 . '/' . $pathinfo['basename'];
+ } else {
+ list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($relPath1);
+ }
+ $targetFilename = basename($relPath2);
+ list($user2, $path2) = \OCA\Files_Sharing\Helper::getUidAndFilename(dirname($relPath2));
+ $rootView = new \OC\Files\View('');
+ return $rootView->rename('/' . $user1 . '/files/' . $path1, '/' . $user2 . '/files/' . $path2 . '/' . $targetFilename);
}
public function copy($path1, $path2) {
@@ -349,13 +357,25 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
case 'xb':
case 'a':
case 'ab':
- $exists = $this->file_exists($path);
- if ($exists && !$this->isUpdatable($path)) {
+ $creatable = $this->isCreatable($path);
+ $updatable = $this->isUpdatable($path);
+ // if neither permissions given, no need to continue
+ if (!$creatable && !$updatable) {
return false;
}
- if (!$exists && !$this->isCreatable(dirname($path))) {
+
+ $exists = $this->file_exists($path);
+ // if a file exists, updatable permissions are required
+ if ($exists && !$updatable) {
return false;
}
+
+ // part file is allowed if !$creatable but the final file is $updatable
+ if (pathinfo($path, PATHINFO_EXTENSION) !== 'part') {
+ if (!$exists && !$creatable) {
+ return false;
+ }
+ }
}
$info = array(
'target' => $this->getMountPoint() . $path,