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
8a4c0829
Commit
8a4c0829
authored
Jan 20, 2016
by
Robin Appelman
Browse files
use insertifnotexists
parent
483c6b68
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/private/files/config/usermountcache.php
View file @
8a4c0829
...
...
@@ -119,30 +119,12 @@ class UserMountCache implements IUserMountCache {
}
private
function
addToCache
(
ICachedMountInfo
$mount
)
{
$builder
=
$this
->
connection
->
getQueryBuilder
();
$query
=
$builder
->
insert
(
'mounts'
)
->
values
([
'storage_id'
=>
':storage'
,
'root_id'
=>
':root'
,
'user_id'
=>
':user'
,
'mount_point'
=>
':mount'
]);
$query
->
setParameters
([
':storage'
=>
$mount
->
getStorageId
(),
':root'
=>
$mount
->
getRootId
(),
':user'
=>
$mount
->
getUser
()
->
getUID
(),
':mount'
=>
$mount
->
getMountPoint
()
$this
->
connection
->
insertIfNotExist
(
'*PREFIX*mounts'
,
[
'storage_id'
=>
$mount
->
getStorageId
(),
'root_id'
=>
$mount
->
getRootId
(),
'user_id'
=>
$mount
->
getUser
()
->
getUID
(),
'mount_point'
=>
$mount
->
getMountPoint
()
]);
try
{
$query
->
execute
();
}
catch
(
UniqueConstraintViolationException
$e
)
{
// seems to mainly happen in tests
// can also happen during concurrent access but we can safely ignore it
// since inserting the same data twice will still result in the correct data being inserted
$this
->
logger
->
error
(
'Duplicate entry while inserting mount'
);
$this
->
logger
->
logException
(
$e
);
}
}
private
function
setMountPoint
(
ICachedMountInfo
$mount
)
{
...
...
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