fix: 修复实时日志与数据库切换可靠性
Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
Sync LobeHub models / sync (push) Has been cancelled

This commit is contained in:
Disy committed 2026-09-27 14:18:25 +08:00
1 parent 2efaa4fb35
commit ce0f41c973
30 files changed
+814 -461

No files matched your search

+20 -12
View File
@@ -1590,6 +1590,15 @@ mod tests {
#[cfg(not(feature = "tauri"))]
#[tokio::test]
async fn import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting()
{
Box::pin(
run_import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting(),
)
.await;
}
#[cfg(not(feature = "tauri"))]
async fn run_import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting()
{
crate::event::EventState::init().await.unwrap();
let root = tempfile::tempdir().unwrap().keep();
@@ -1788,18 +1797,17 @@ mod tests {
.await
.unwrap();
assert_eq!(observed.pending, 1);
let (scan_result, manual_result) = tokio::join!(
scan_missing_modpack_files_in_at(
job_id,
&race_downloads,
first_seen + DOWNLOAD_STABILITY_WINDOW,
),
import_missing_modpack_file(
job_id,
first.item_id.clone(),
selected,
)
);
let scan = Box::pin(scan_missing_modpack_files_in_at(
job_id,
&race_downloads,
first_seen + DOWNLOAD_STABILITY_WINDOW,
));
let manual = Box::pin(import_missing_modpack_file(
job_id,
first.item_id.clone(),
selected,
));
let (scan_result, manual_result) = tokio::join!(scan, manual);
let scan_result = scan_result.unwrap();
assert!(manual_result.is_ok());
assert!(
+16 -6
View File
@@ -13,7 +13,10 @@ use crate::state::{
use chrono::{DateTime, Utc};
use modrinth_content_management::{ContentType, ResolutionPreferences};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
use std::{
collections::{HashMap, HashSet},
path::PathBuf,
};
use uuid::Uuid;
pub type InstallModpackPreview = CreatePackInstance;
@@ -483,7 +486,7 @@ mod tests {
assert_eq!(summary.bytes_total, Some(300));
let items = job.download_items();
assert_eq!(items.len(), 3);
assert_eq!(items[0].status, DownloadItemStatus::Verifying);
assert_eq!(items[0].status, DownloadItemStatus::Completed);
assert_eq!(items[0].attempt, Some(1));
assert_eq!(items[0].max_attempts, Some(4));
assert_eq!(
@@ -2395,6 +2398,7 @@ impl InstallJobState {
fn download_items_from_events(&self) -> Vec<DownloadItemSnapshot> {
let mut items = Vec::<DownloadItemSnapshot>::new();
let mut indices = HashMap::<String, usize>::new();
let mut content_items = HashSet::<String>::new();
for event in &self.events {
match &event.kind {
InstallJobEventKind::ContentFileQueued {
@@ -2402,6 +2406,7 @@ impl InstallJobState {
bytes_total,
max_attempts,
} => {
content_items.insert(path.clone());
if let Some(item) = indices
.get(path)
.and_then(|&index| items.get_mut(index))
@@ -2482,6 +2487,7 @@ impl InstallJobState {
attempt,
max_attempts,
} => {
content_items.insert(path.clone());
if let Some(item) = indices
.get(path)
.and_then(|&index| items.get_mut(index))
@@ -2562,10 +2568,14 @@ impl InstallJobState {
.get(path)
.and_then(|&index| items.get_mut(index))
{
// Network transfer completion is not content
// finalization. `ContentFileCompleted` is the event
// that confirms verification and DB registration.
item.status = DownloadItemStatus::Verifying;
// Content downloads still need verification and DB
// registration. Standalone Java/Minecraft requests
// are final once the request itself finishes.
item.status = if content_items.contains(path) {
DownloadItemStatus::Verifying
} else {
DownloadItemStatus::Completed
};
item.bytes_downloaded = *bytes;
item.bytes_total = item.bytes_total.or(Some(*bytes));
}
+3 -4
View File
@@ -1361,12 +1361,11 @@ mod tests {
assert_eq!(persisted.status, InstallJobStatus::Canceled);
assert!(persisted.state.rollback.as_ref().unwrap().content.is_none());
assert!(persisted.state.rollback_error.is_none());
assert_eq!(
crate::state::list_instances(&state.pool)
assert!(
crate::state::get_instance(&instance_id, &state.pool)
.await
.unwrap()
.len(),
1
.is_some()
);
let new_instance = crate::api::instance::create(