aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-01-11 13:06:10 +0100
committerRobin Appelman <icewind@owncloud.com>2016-01-20 16:32:56 +0100
commitbc7bd0cd0532b8309d317c23ee4f13106e0a0e1d (patch)
tree85549c233e566a7fd24cfc99e58d23f83b8175c8 /lib/private/files
parentbe380accb90d0a4f72a56a1166072b20731b0083 (diff)
downloadnextcloud-server-bc7bd0cd0532b8309d317c23ee4f13106e0a0e1d.tar.gz
nextcloud-server-bc7bd0cd0532b8309d317c23ee4f13106e0a0e1d.zip
handle changed mount points
Diffstat (limited to 'lib/private/files')
-rw-r--r--lib/private/files/config/usermountcache.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/private/files/config/usermountcache.php b/lib/private/files/config/usermountcache.php
index fb46e70fa5c..e60c6d0400b 100644
--- a/lib/private/files/config/usermountcache.php
+++ b/lib/private/files/config/usermountcache.php
@@ -96,6 +96,14 @@ class UserMountCache implements IUserMountCache {
/** @var ICachedMountInfo[] $removedMounts */
$removedMounts = array_udiff($cachedMounts, $newMounts, $mountDiff);
+ $changedMounts = array_uintersect($newMounts, $cachedMounts, function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) {
+ // filter mounts with the same root id and different mountpoints
+ if ($mount1->getRootId() !== $mount2->getRootId()) {
+ return -1;
+ }
+ return ($mount1->getMountPoint() !== $mount2->getMountPoint()) ? 0 : 1;
+ });
+
foreach ($addedMounts as $mount) {
$this->addToCache($mount);
$this->mountsForUsers[$user->getUID()][] = $mount;
@@ -105,6 +113,9 @@ class UserMountCache implements IUserMountCache {
$index = array_search($mount, $this->mountsForUsers[$user->getUID()]);
unset($this->mountsForUsers[$user->getUID()][$index]);
}
+ foreach ($changedMounts as $mount) {
+ $this->setMountPoint($mount);
+ }
}
private function addToCache(ICachedMountInfo $mount) {
@@ -134,6 +145,17 @@ class UserMountCache implements IUserMountCache {
}
}
+ private function setMountPoint(ICachedMountInfo $mount) {
+ $builder = $this->connection->getQueryBuilder();
+
+ $query = $builder->update('mounts')
+ ->set('mount_point', $builder->createNamedParameter($mount->getMountPoint()))
+ ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
+ ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), \PDO::PARAM_INT)));
+
+ $query->execute();
+ }
+
private function removeFromCache(ICachedMountInfo $mount) {
$builder = $this->connection->getQueryBuilder();
@@ -205,7 +227,7 @@ class UserMountCache implements IUserMountCache {
$builder = $this->connection->getQueryBuilder();
$query = $builder->delete('mounts')
- ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID())));
+ ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID())));
$query->execute();
}
}