mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 09:04:55 +00:00
fix: always check for updates/clear cache 10 min cooldown (#7077)
This commit is contained in:
@@ -16,7 +16,7 @@ pub use self::content::{
|
||||
get_content_items, get_dependencies_as_content_items,
|
||||
get_install_candidates, get_installed_project_ids,
|
||||
get_linked_modpack_content, get_linked_modpack_info, get_projects,
|
||||
list_content_sets, sync_content_files,
|
||||
list_content_sets, refresh_content_updates, sync_content_files,
|
||||
};
|
||||
pub use self::export_mrpack::{
|
||||
PackExportCandidate, create_mrpack_json, export_mrpack,
|
||||
|
||||
@@ -74,6 +74,12 @@ pub async fn get_content_items(
|
||||
crate::state::list_content(instance_id, None, cache_behaviour, &state).await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn refresh_content_updates(instance_id: &str) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
crate::state::refresh_content_updates(instance_id, &state).await
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn get_linked_modpack_content(
|
||||
instance_id: &str,
|
||||
|
||||
@@ -30,6 +30,36 @@ pub(crate) async fn check_content_updates(
|
||||
instance_id: &str,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
state: &State,
|
||||
) -> crate::Result<Vec<ContentUpdate>> {
|
||||
check_content_updates_with_cache_behaviours(
|
||||
instance_id,
|
||||
cache_behaviour,
|
||||
cache_behaviour,
|
||||
state,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn refresh_content_updates(
|
||||
instance_id: &str,
|
||||
state: &State,
|
||||
) -> crate::Result<()> {
|
||||
check_content_updates_with_cache_behaviours(
|
||||
instance_id,
|
||||
None,
|
||||
Some(CacheBehaviour::Bypass),
|
||||
state,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn check_content_updates_with_cache_behaviours(
|
||||
instance_id: &str,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
update_cache_behaviour: Option<CacheBehaviour>,
|
||||
state: &State,
|
||||
) -> crate::Result<Vec<ContentUpdate>> {
|
||||
let instance = instance_rows::get_instance_by_id(instance_id, &state.pool)
|
||||
.await?
|
||||
@@ -113,7 +143,7 @@ pub(crate) async fn check_content_updates(
|
||||
.collect::<Vec<_>>();
|
||||
let updates = CachedEntry::get_file_update_many(
|
||||
&update_key_refs,
|
||||
cache_behaviour,
|
||||
update_cache_behaviour,
|
||||
&state.pool,
|
||||
&state.api_semaphore,
|
||||
)
|
||||
|
||||
@@ -38,6 +38,7 @@ mod apply_content_install;
|
||||
pub(crate) use self::apply_content_install::*;
|
||||
|
||||
mod check_content_updates;
|
||||
pub(crate) use self::check_content_updates::refresh_content_updates;
|
||||
|
||||
mod apply_content_update;
|
||||
pub(crate) use self::apply_content_update::*;
|
||||
|
||||
@@ -22,6 +22,6 @@ pub(crate) use self::commands::{
|
||||
dependencies_to_content_items, get_content_projects,
|
||||
get_installed_project_ids_for_instance, get_instance_install_candidates,
|
||||
get_linked_modpack_info, list_content, list_content_sets,
|
||||
list_linked_modpack_content, sync_content_files,
|
||||
list_linked_modpack_content, refresh_content_updates, sync_content_files,
|
||||
};
|
||||
pub(crate) mod watcher;
|
||||
|
||||
Reference in New Issue
Block a user