summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();
}
}