summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-03-22 13:12:54 -0600
committerGitHub <noreply@github.com>2017-03-22 13:12:54 -0600
commite25b997d0b484c4cb428f0928360c840d71b7882 (patch)
treeb12f0a68267f536546fd5660f88f2e8d30dd6c28
parent8b75e9b8a01f4dcd8404d1231f96461a4f405c67 (diff)
parent1e707ef1db10f3d399099ee4ab1ef10f0531eac5 (diff)
downloadnextcloud-server-e25b997d0b484c4cb428f0928360c840d71b7882.tar.gz
nextcloud-server-e25b997d0b484c4cb428f0928360c840d71b7882.zip
Merge pull request #3497 from nextcloud/mount-shared-last
mount shared mounts last
-rw-r--r--build/integration/features/external-storage.feature18
-rwxr-xr-xbuild/integration/run.sh2
-rw-r--r--lib/private/Files/Config/MountProviderCollection.php33
-rw-r--r--lib/private/Files/Filesystem.php3
4 files changed, 52 insertions, 4 deletions
diff --git a/build/integration/features/external-storage.feature b/build/integration/features/external-storage.feature
index 7fbdf828fb8..da085d9e983 100644
--- a/build/integration/features/external-storage.feature
+++ b/build/integration/features/external-storage.feature
@@ -23,4 +23,20 @@ Feature: external-storage
| token | A_TOKEN |
| mimetype | httpd/unix-directory |
-
+ @local_storage
+ Scenario: Shares dont overwrite external storages
+ Given user "user0" exists
+ And user "user1" exists
+ And As an "user0"
+ And User "user0" moved file "/textfile0.txt" to "/local_storage/textfile0.txt"
+ And invoking occ with "files_external:create --user user0 test local null::null -c datadir=./build/integration/work/local_storage"
+ And invoking occ with "files:scan --path /user0/files/test"
+ And as "user0" the file "/local_storage/textfile0.txt" exists
+ And as "user0" the folder "/test" exists
+ And as "user0" the file "/test/textfile0.txt" exists
+ And As an "user1"
+ And user "user1" created a folder "/test"
+ And User "user1" moved file "/textfile0.txt" to "/test/textfile1.txt"
+ And folder "/test" of user "user1" is shared with user "user0"
+ And As an "user0"
+ Then as "user0" the file "/test/textfile1.txt" does not exist
diff --git a/build/integration/run.sh b/build/integration/run.sh
index 83600d8323e..f423c3e6fb7 100755
--- a/build/integration/run.sh
+++ b/build/integration/run.sh
@@ -46,7 +46,7 @@ if [ "$INSTALLED" == "true" ]; then
mkdir -p work/local_storage
OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=./build/integration/work/local_storage`
- ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | awk {'print $5'}`
+ ID_STORAGE=`echo $OUTPUT_CREATE_STORAGE | tr ' ' '\n' | tail -n1`
$OCC files_external:option $ID_STORAGE enable_sharing true
diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php
index a09f246e6b3..f3252f0fd65 100644
--- a/lib/private/Files/Config/MountProviderCollection.php
+++ b/lib/private/Files/Config/MountProviderCollection.php
@@ -29,6 +29,7 @@ use OCP\Files\Config\IHomeMountProvider;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Config\IUserMountCache;
+use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
@@ -84,6 +85,37 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
}, array());
}
+ public function addMountForUser(IUser $user, IMountManager $mountManager) {
+ // shared mount provider gets to go last since it needs to know existing files
+ // to check for name collisions
+ $firstMounts = [];
+ $firstProviders = array_filter($this->providers, function (IMountProvider $provider) {
+ return (get_class($provider) !== 'OCA\Files_Sharing\MountProvider');
+ });
+ $lastProviders = array_filter($this->providers, function (IMountProvider $provider) {
+ return (get_class($provider) === 'OCA\Files_Sharing\MountProvider');
+ });
+ foreach ($firstProviders as $provider) {
+ $mounts = $provider->getMountsForUser($user, $this->loader);
+ if (is_array($mounts)) {
+ $firstMounts = array_merge($firstMounts, $mounts);
+ }
+ }
+ array_walk($firstMounts, [$mountManager, 'addMount']);
+
+ $lateMounts = [];
+ foreach ($lastProviders as $provider) {
+ $mounts = $provider->getMountsForUser($user, $this->loader);
+ if (is_array($mounts)) {
+ $lateMounts = array_merge($lateMounts, $mounts);
+ }
+ }
+
+ array_walk($lateMounts, [$mountManager, 'addMount']);
+
+ return array_merge($lateMounts, $firstMounts);
+ }
+
/**
* Get the configured home mount for this user
*
@@ -110,6 +142,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
*/
public function registerProvider(IMountProvider $provider) {
$this->providers[] = $provider;
+
$this->emit('\OC\Files\Config', 'registerMountProvider', [$provider]);
}
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 51e494c372e..22b14e44074 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -443,8 +443,7 @@ class Filesystem {
// Chance to mount for other storages
if ($userObject) {
- $mounts = $mountConfigManager->getMountsForUser($userObject);
- array_walk($mounts, array(self::$mounts, 'addMount'));
+ $mounts = $mountConfigManager->addMountForUser($userObject, self::getMountManager());
$mounts[] = $homeMount;
$mountConfigManager->registerMounts($userObject, $mounts);
}