⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const_format = "0.2.34"
daedalus = { path = "packages/daedalus" }
dashmap = "6.1.0"
data-url = "0.3.2"
deadpool-redis = "0.22.0"
deadpool-redis = { version ="0.22.0", features = ["cluster-async"] }
derive_more = "2.0.1"
directories = "6.0.0"
dirs = "6.0.0"
Expand Down
7 changes: 4 additions & 3 deletions apps/labrinth/src/database/models/notification_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,10 @@ impl DBNotification {
let mut redis = redis.connect().await?;

redis
.delete_many(user_ids.into_iter().map(|id| {
(USER_NOTIFICATIONS_NAMESPACE, Some(id.0.to_string()))
}))
.delete_many(
USER_NOTIFICATIONS_NAMESPACE,
user_ids.into_iter().map(|id| Some(id.0.to_string())),
)
.await?;

Ok(())
Expand Down
15 changes: 8 additions & 7 deletions apps/labrinth/src/database/models/organization_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,16 @@ impl DBOrganization {
) -> Result<(), super::DatabaseError> {
let mut redis = redis.connect().await?;

if let Some(slug) = slug {
redis
.delete(ORGANIZATIONS_TITLES_NAMESPACE, slug.to_lowercase())
.await?;
}

redis
.delete_many([
(ORGANIZATIONS_NAMESPACE, Some(id.0.to_string())),
(
ORGANIZATIONS_TITLES_NAMESPACE,
slug.map(|x| x.to_lowercase()),
),
])
.delete(ORGANIZATIONS_NAMESPACE, id.0.to_string())
.await?;

Ok(())
}
}
32 changes: 20 additions & 12 deletions apps/labrinth/src/database/models/pat_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,26 @@ impl DBPersonalAccessToken {
}

redis
.delete_many(clear_pats.into_iter().flat_map(
|(id, token, user_id)| {
[
(PATS_NAMESPACE, id.map(|i| i.0.to_string())),
(PATS_TOKENS_NAMESPACE, token),
(
PATS_USERS_NAMESPACE,
user_id.map(|i| i.0.to_string()),
),
]
},
))
.delete_many(
PATS_NAMESPACE,
clear_pats
.iter()
.map(|(x, _, _)| x.map(|i| i.0.to_string())),
)
.await?;
redis
.delete_many(
PATS_TOKENS_NAMESPACE,
clear_pats.iter().map(|(_, token, _)| token.clone()),
)
.await?;
redis
.delete_many(
PATS_USERS_NAMESPACE,
clear_pats
.iter()
.map(|(_, _, x)| x.map(|i| i.0.to_string())),
)
.await?;

Ok(())
Expand Down
28 changes: 14 additions & 14 deletions apps/labrinth/src/database/models/project_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,20 +953,20 @@ impl DBProject {
) -> Result<(), DatabaseError> {
let mut redis = redis.connect().await?;

redis
.delete_many([
(PROJECTS_NAMESPACE, Some(id.0.to_string())),
(PROJECTS_SLUGS_NAMESPACE, slug.map(|x| x.to_lowercase())),
(
PROJECTS_DEPENDENCIES_NAMESPACE,
if clear_dependencies.unwrap_or(false) {
Some(id.0.to_string())
} else {
None
},
),
])
.await?;
redis.delete(PROJECTS_NAMESPACE, id.0.to_string()).await?;

if let Some(slug) = slug {
redis
.delete(PROJECTS_SLUGS_NAMESPACE, slug.to_lowercase())
.await?;
}

if clear_dependencies.unwrap_or(false) {
redis
.delete(PROJECTS_DEPENDENCIES_NAMESPACE, id.0.to_string())
.await?;
}

Ok(())
}
}
Expand Down
33 changes: 21 additions & 12 deletions apps/labrinth/src/database/models/session_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,28 @@ impl DBSession {
}

redis
.delete_many(clear_sessions.into_iter().flat_map(
|(id, session, user_id)| {
[
(SESSIONS_NAMESPACE, id.map(|i| i.0.to_string())),
(SESSIONS_IDS_NAMESPACE, session),
(
SESSIONS_USERS_NAMESPACE,
user_id.map(|i| i.0.to_string()),
),
]
},
))
.delete_many(
SESSIONS_NAMESPACE,
clear_sessions
.iter()
.map(|(x, _, _)| x.map(|x| x.0.to_string())),
)
.await?;
redis
.delete_many(
SESSIONS_IDS_NAMESPACE,
clear_sessions.iter().map(|(_, session, _)| session.clone()),
)
.await?;
redis
.delete_many(
SESSIONS_USERS_NAMESPACE,
clear_sessions
.iter()
.map(|(_, _, x)| x.map(|x| x.0.to_string())),
)
.await?;

Ok(())
}

Expand Down
24 changes: 12 additions & 12 deletions apps/labrinth/src/database/models/user_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,16 @@ impl DBUser {
let mut redis = redis.connect().await?;

redis
.delete_many(user_ids.iter().flat_map(|(id, username)| {
[
(USERS_NAMESPACE, Some(id.0.to_string())),
(
USER_USERNAMES_NAMESPACE,
username.clone().map(|i| i.to_lowercase()),
),
]
}))
.delete_many(
USERS_NAMESPACE,
user_ids.iter().map(|(id, _)| Some(id.0.to_string())),
)
.await?;
redis
.delete_many(
USER_USERNAMES_NAMESPACE,
user_ids.iter().map(|(_, username)| username.clone()),
)
.await?;
Ok(())
}
Expand All @@ -491,9 +492,8 @@ impl DBUser {

redis
.delete_many(
user_ids.iter().map(|id| {
(USERS_PROJECTS_NAMESPACE, Some(id.0.to_string()))
}),
USERS_PROJECTS_NAMESPACE,
user_ids.iter().map(|id| Some(id.0.to_string())),
)
.await?;

Expand Down
26 changes: 11 additions & 15 deletions apps/labrinth/src/database/models/version_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::iter;

pub const VERSIONS_NAMESPACE: &str = "versions";
const VERSION_FILES_NAMESPACE: &str = "versions_files";
Expand Down Expand Up @@ -914,24 +913,21 @@ impl DBVersion {
) -> Result<(), DatabaseError> {
let mut redis = redis.connect().await?;

redis
.delete(VERSIONS_NAMESPACE, version.inner.id.0.to_string())
.await?;

redis
.delete_many(
iter::once((
VERSIONS_NAMESPACE,
Some(version.inner.id.0.to_string()),
))
.chain(version.files.iter().flat_map(
|file| {
file.hashes.iter().map(|(algo, hash)| {
(
VERSION_FILES_NAMESPACE,
Some(format!("{algo}_{hash}")),
)
})
},
)),
VERSION_FILES_NAMESPACE,
version.files.iter().flat_map(|file| {
file.hashes
.iter()
.map(|(algo, hash)| Some(format!("{algo}_{hash}")))
}),
)
.await?;

Ok(())
}
}
Expand Down
Loading
Loading