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

@@ -16,6 +16,12 @@ use chrono::{DateTime, TimeZone, Utc};
use sqlx::{Executor, Row, Sqlite, SqlitePool, Transaction};
use uuid::Uuid;
async fn begin_content_write(
pool: &SqlitePool,
) -> crate::Result<Transaction<'static, Sqlite>> {
Ok(pool.begin_with("BEGIN IMMEDIATE").await?)
}
/// Ensures the instance a content write is about to reference still exists.
///
/// Runs inside the write transaction so a concurrent instance deletion that
@@ -662,7 +668,7 @@ pub(crate) async fn upsert_instance_file_from_parts(
input: UpsertInstanceFile<'_>,
pool: &SqlitePool,
) -> crate::Result<InstanceFile> {
let mut tx = pool.begin().await?;
let mut tx = begin_content_write(pool).await?;
let file =
upsert_instance_file_from_parts_in_transaction(input, &mut tx).await?;
tx.commit().await?;
@@ -726,7 +732,7 @@ pub(crate) async fn rename_instance_file(
enabled: bool,
pool: &SqlitePool,
) -> crate::Result<Option<InstanceFile>> {
let mut tx = pool.begin().await?;
let mut tx = begin_content_write(pool).await?;
let file = rename_instance_file_in_transaction(
instance_id,
@@ -1106,7 +1112,7 @@ pub(crate) async fn upsert_content_entry_from_parts(
input: UpsertContentEntry<'_>,
pool: &SqlitePool,
) -> crate::Result<ContentEntry> {
let mut tx = pool.begin().await?;
let mut tx = begin_content_write(pool).await?;
let entry =
upsert_content_entry_from_parts_in_transaction(input, &mut tx).await?;
tx.commit().await?;
@@ -1230,7 +1236,7 @@ pub(crate) async fn upsert_content_provider_ref(
origin: bool,
pool: &SqlitePool,
) -> crate::Result<()> {
let mut tx = pool.begin().await?;
let mut tx = begin_content_write(pool).await?;
upsert_content_provider_ref_in_transaction(
content_entry_id,
provider_ref,
@@ -2583,6 +2589,7 @@ mod tests {
provider TEXT NOT NULL,
provider_project_id TEXT NOT NULL,
provider_release_id TEXT NULL,
provider_file_id TEXT NULL,
is_origin INTEGER NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX instance_content_provider_refs_identity
@@ -539,7 +539,7 @@ pub(crate) async fn persist_resolved_plan_dependency_edges(
.chain(plan.dependencies.iter())
.collect::<Vec<_>>();
let mut tx = state.pool.begin().await?;
let mut tx = begin_content_write(&state.pool).await?;
for (index, dependency) in plan.dependencies.iter().enumerate() {
let Some(parent) = dependency
.dependent_on_version_id
@@ -254,8 +254,8 @@ mod tests {
instance_rows::get_instance_by_id(&instance.id, &state.pool)
.await?
.expect("instance row");
let canonical_root = minecraft.path().canonicalize()?;
let canonical_json = json_path.canonicalize()?;
let canonical_root = crate::util::io::canonicalize(minecraft.path())?;
let canonical_json = crate::util::io::canonicalize(&json_path)?;
assert_eq!(stored.linked_launcher.as_deref(), Some("generic"));
assert_eq!(
stored.linked_launcher_root.as_deref(),