Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Nextcloud Notify Push
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Trujillo
Nextcloud Notify Push
Commits
4363ce26
Commit
4363ce26
authored
3 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
cleanup storage mapping fetching
Signed-off-by:
Robin Appelman
<
robin@icewind.nl
>
parent
d3cc6251
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/storage_mapping.rs
+14
-15
14 additions, 15 deletions
src/storage_mapping.rs
with
14 additions
and
15 deletions
src/storage_mapping.rs
+
14
−
15
View file @
4363ce26
use
crate
::
metrics
::
METRICS
;
use
crate
::
UserId
;
use
color_eyre
::{
eyre
::
WrapErr
,
Result
};
use
dashmap
::
mapref
::
one
::
Ref
;
use
dashmap
::
DashMap
;
use
rand
::{
thread_rng
,
Rng
};
use
sqlx
::
any
::
AnyConnectOptions
;
...
...
@@ -59,25 +60,23 @@ impl StorageMapping {
Self
::
from_connection
(
connection
,
prefix
)
.await
}
pub
async
fn
get_users_for_storage_path
<
'a
>
(
&
self
,
storage
:
u32
,
path
:
&
str
,
)
->
Result
<
impl
Iterator
<
Item
=
UserId
>>
{
let
cached
=
if
let
Some
(
cached
)
=
self
.cache
.get
(
&
storage
)
.and_then
(|
cached
|
{
if
cached
.is_valid
()
{
Some
(
cached
)
}
else
{
None
}
})
{
cached
async
fn
get_storage_mapping
<
'a
>
(
&
'a
self
,
storage
:
u32
)
->
Result
<
Ref
<
'a
,
u32
,
CachedAccess
>>
{
if
let
Some
(
cached
)
=
self
.cache
.get
(
&
storage
)
.filter
(|
cached
|
cached
.is_valid
())
{
Ok
(
cached
)
}
else
{
let
users
=
self
.load_storage_mapping
(
storage
)
.await
?
;
self
.cache
.insert
(
storage
,
CachedAccess
::
new
(
users
));
self
.cache
.get
(
&
storage
)
.unwrap
()
};
Ok
(
self
.cache
.get
(
&
storage
)
.unwrap
())
}
}
pub
async
fn
get_users_for_storage_path
(
&
self
,
storage
:
u32
,
path
:
&
str
,
)
->
Result
<
impl
Iterator
<
Item
=
UserId
>>
{
let
cached
=
self
.get_storage_mapping
(
storage
)
.await
?
;
Ok
(
cached
.access
.iter
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment