diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-04-25 11:47:06 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-04-25 11:47:06 +0200 |
commit | 6c20a014eaecd19c3f68143485c6f74891ee9643 (patch) | |
tree | 84bd8e37536e7f28a25afd7586c209d38a25d610 /lib/private/files | |
parent | cd0c5990f895bcdce47acf2dbf11ebadd920a404 (diff) | |
parent | 3fc809dfd80a296d7da922a06f9e13d446b3d3f0 (diff) | |
download | nextcloud-server-6c20a014eaecd19c3f68143485c6f74891ee9643.tar.gz nextcloud-server-6c20a014eaecd19c3f68143485c6f74891ee9643.zip |
merge master into webdav-injection
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/filesystem.php | 3 | ||||
-rw-r--r-- | lib/private/files/mount/manager.php | 7 | ||||
-rw-r--r-- | lib/private/files/mount/mount.php | 7 | ||||
-rw-r--r-- | lib/private/files/view.php | 37 |
4 files changed, 43 insertions, 11 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 7e27650c557..434ee495870 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -374,6 +374,9 @@ class Filesystem { * Returns path like /admin/files */ static public function getRoot() { + if (!self::$defaultInstance) { + return null; + } return self::$defaultInstance->getRoot(); } diff --git a/lib/private/files/mount/manager.php b/lib/private/files/mount/manager.php index ff4a336f347..91460b72730 100644 --- a/lib/private/files/mount/manager.php +++ b/lib/private/files/mount/manager.php @@ -24,6 +24,13 @@ class Manager { } /** + * @param string $mountPoint + */ + public function removeMount($mountPoint) { + unset($this->mounts[$mountPoint]); + } + + /** * Find the mount for $path * * @param $path diff --git a/lib/private/files/mount/mount.php b/lib/private/files/mount/mount.php index 0ce2f5975c7..08d5ddf348b 100644 --- a/lib/private/files/mount/mount.php +++ b/lib/private/files/mount/mount.php @@ -66,6 +66,13 @@ class Mount { } /** + * @param string $mountPoint new mount point + */ + public function setMountPoint($mountPoint) { + $this->mountPoint = $mountPoint; + } + + /** * create the storage that is mounted * * @return \OC\Files\Storage\Storage diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 519ed250b1f..58dfc73dcf3 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -348,7 +348,8 @@ class View { $postFix = (substr($path, -1, 1) === '/') ? '/' : ''; $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); - if (!$internalPath || $internalPath === '' || $internalPath === '/') { + if (!($storage instanceof \OC\Files\Storage\Shared) && + (!$internalPath || $internalPath === '' || $internalPath === '/')) { // do not allow deleting the storage's root / the mount point // because for some storages it might delete the whole contents // but isn't supposed to work that way @@ -404,11 +405,21 @@ class View { if ($run) { $mp1 = $this->getMountPoint($path1 . $postFix1); $mp2 = $this->getMountPoint($path2 . $postFix2); - if ($mp1 == $mp2) { - list($storage, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); - list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2); - if ($storage) { - $result = $storage->rename($internalPath1, $internalPath2); + list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); + list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2); + // if source and target are on the same storage we can call the rename operation from the + // storage. If it is a "Shared" file/folder we call always the rename operation of the + // shared storage to handle mount point renaming, etc correctly + if ($storage1 instanceof \OC\Files\Storage\Shared) { + if ($storage1) { + $result = $storage1->rename($absolutePath1, $absolutePath2); + \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2); + } else { + $result = false; + } + } elseif ($mp1 == $mp2) { + if ($storage1) { + $result = $storage1->rename($internalPath1, $internalPath2); \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2); } else { $result = false; @@ -417,7 +428,6 @@ class View { if ($this->is_dir($path1)) { $result = $this->copy($path1, $path2); if ($result === true) { - list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); $result = $storage1->unlink($internalPath1); } } else { @@ -431,7 +441,6 @@ class View { fclose($target); if ($result !== false) { - list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); $storage1->unlink($internalPath1); } } @@ -972,8 +981,13 @@ class View { $permissions = $subStorage->getPermissions($rootEntry['path']); $subPermissionsCache->set($rootEntry['fileid'], $user, $permissions); } - // do not allow renaming/deleting the mount point - $rootEntry['permissions'] = $permissions & (\OCP\PERMISSION_ALL - (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE)); + // do not allow renaming/deleting the mount point if they are not shared files/folders + // for shared files/folders we use the permissions given by the owner + if ($subStorage instanceof \OC\Files\Storage\Shared) { + $rootEntry['permissions'] = $permissions; + } else { + $rootEntry['permissions'] = $permissions & (\OCP\PERMISSION_ALL - (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE)); + } //remove any existing entry with the same name foreach ($files as $i => $file) { @@ -1154,7 +1168,8 @@ class View { * @var \OC\Files\Mount\Mount $mount */ $cache = $mount->getStorage()->getCache(); - if ($internalPath = $cache->getPathById($id)) { + $internalPath = $cache->getPathById($id); + if (is_string($internalPath)) { $fullPath = $mount->getMountPoint() . $internalPath; if (!is_null($path = $this->getRelativePath($fullPath))) { return $path; |