Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
bc7bd0cd
Commit
bc7bd0cd
authored
Jan 11, 2016
by
Robin Appelman
Browse files
handle changed mount points
parent
be380acc
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/private/files/config/usermountcache.php
View file @
bc7bd0cd
...
...
@@ -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
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment