style: 对跨实例同步移植代码执行 cargo fmt
Sync source to CNB / Sync Git ref (push) Has been cancelled

This commit is contained in:
AxTps committed 2026-10-04 07:42:48 +08:00
1 parent 6e9485c2f5
commit fae16a0184
21 files changed
+35 -40

No files matched your search

+1 -1
View File
@@ -15,8 +15,8 @@ mod projects;
mod run; mod run;
mod screenshot_groups; mod screenshot_groups;
mod screenshots; mod screenshots;
mod upgrade;
pub(crate) mod synced_options; pub(crate) mod synced_options;
mod upgrade;
pub(crate) mod synced_packs { pub(crate) mod synced_packs {
pub(crate) use super::synced_packs_axolotl::{ pub(crate) use super::synced_packs_axolotl::{
capture_resource_pack_selection_change, detach, capture_resource_pack_selection_change, detach,
@@ -200,4 +200,4 @@ pub(super) fn canonical_values_equal(
} }
_ => left == right, _ => left == right,
} }
} }
@@ -204,4 +204,4 @@ pub(super) const SETTINGS: &[SupportedSetting] = &[
BOOL, BOOL,
ValueEncoding::Bool, ValueEncoding::Bool,
), ),
]; ];
@@ -191,4 +191,4 @@ pub(super) const SETTINGS: &[SupportedSetting] = &[
SettingEditor::Enum(CHAT_PREVIEW), SettingEditor::Enum(CHAT_PREVIEW),
ValueEncoding::ChatPreview, ValueEncoding::ChatPreview,
), ),
]; ];
@@ -410,4 +410,4 @@ pub(super) const SETTINGS: &[SupportedSetting] = &[
"26.3", "26.3",
"26.3" "26.3"
), ),
]; ];
@@ -124,4 +124,4 @@ pub(in crate::api::instance) const LEGACY_DATA_VERSIONS: phf::Map<&str, u32> = p
"1.10" => 510, "1.10" => 510,
"1.10-pre2" => 507, "1.10-pre2" => 507,
"1.10-pre1" => 506, "1.10-pre1" => 506,
}; };
@@ -252,4 +252,4 @@ pub(super) const KNOWN_VANILLA_KEYS: &[&str] = &[
"modelPart_right_pants_leg", "modelPart_right_pants_leg",
"modelPart_hat", "modelPart_hat",
"fullscreenResolution", "fullscreenResolution",
]; ];
@@ -109,4 +109,4 @@ pub(in crate::api::instance) const LEGACY_KEY_BINDINGS: &[(i32, &str)] = &[
(211, "key.keyboard.delete"), (211, "key.keyboard.delete"),
(219, "key.keyboard.left.win"), (219, "key.keyboard.left.win"),
(220, "key.keyboard.right.win"), (220, "key.keyboard.right.win"),
]; ];
@@ -174,4 +174,4 @@ pub(super) const SETTINGS: &[SupportedSetting] = &[
UNIT_INTERVAL, UNIT_INTERVAL,
ValueEncoding::Decimal, ValueEncoding::Decimal,
), ),
]; ];
@@ -447,4 +447,4 @@ pub(super) const SETTINGS: &[SupportedSetting] = &[
BOOL, BOOL,
ValueEncoding::Bool, ValueEncoding::Bool,
), ),
]; ];
@@ -75,4 +75,4 @@ const CATALOG_REVISION: u32 = 6;
const MAX_OPTIONS_BYTES: usize = 2 * 1024 * 1024; const MAX_OPTIONS_BYTES: usize = 2 * 1024 * 1024;
const MAX_OPTIONS_LINES: usize = 16_384; const MAX_OPTIONS_LINES: usize = 16_384;
const MAX_KEY_BYTES: usize = 1_024; const MAX_KEY_BYTES: usize = 1_024;
const MAX_VALUE_BYTES: usize = 32 * 1024; const MAX_VALUE_BYTES: usize = 32 * 1024;
@@ -357,4 +357,4 @@ pub(super) async fn read_document(
let bytes = io::read(path).await?; let bytes = io::read(path).await?;
let document = GameOptionsDocument::parse(&bytes)?; let document = GameOptionsDocument::parse(&bytes)?;
Ok((document, bytes)) Ok((document, bytes))
} }
@@ -29,4 +29,4 @@ pub(crate) use self::orchestration::{
monitor_persisted_processes, prepare_instance_update, monitor_persisted_processes, prepare_instance_update,
reconcile_instance_after_pack_update_with_state, reconcile_instance_after_pack_update_with_state,
remove_generated_instance_files, remove_generated_instance_files,
}; };
@@ -28,7 +28,9 @@ use super::hotbars::{
read_hotbar_state, reconcile_hotbar, regenerate_hotbars, read_hotbar_state, reconcile_hotbar, regenerate_hotbars,
write_hotbar_state, write_hotbar_state,
}; };
use super::pending::{self, PendingAction, PendingChange, SyncedOptionJoinResolution}; use super::pending::{
self, PendingAction, PendingChange, SyncedOptionJoinResolution,
};
use super::{COMMAND_HISTORY_FILE, HOTBAR_FILE}; use super::{COMMAND_HISTORY_FILE, HOTBAR_FILE};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
@@ -981,12 +983,11 @@ pub async fn reconcile_all() -> crate::Result<()> {
pub(crate) async fn monitor_persisted_processes() -> crate::Result<()> { pub(crate) async fn monitor_persisted_processes() -> crate::Result<()> {
let state = State::get().await?; let state = State::get().await?;
let instance_ids = let instance_ids = sqlx::query_scalar::<_, String>(
sqlx::query_scalar::<_, String>( "SELECT DISTINCT instance_id FROM processes",
"SELECT DISTINCT instance_id FROM processes", )
) .fetch_all(&state.pool)
.fetch_all(&state.pool) .await?;
.await?;
for instance_id in instance_ids { for instance_id in instance_ids {
tokio::spawn(async move { tokio::spawn(async move {
loop { loop {
@@ -101,4 +101,4 @@ pub(in crate::api::instance) async fn contains(
Ok(read(state).await?.iter().any(|change| { Ok(read(state).await?.iter().any(|change| {
change.instance_id == instance_id && change.option == option change.instance_id == instance_id && change.option == option
})) }))
} }
@@ -212,13 +212,11 @@ async fn load_local_with<'e>(
let position: i64 = row.get("position"); let position: i64 = row.get("position");
Ok(LocalServer { Ok(LocalServer {
id, id,
source: ServerSource::from_str(&source).ok_or_else( source: ServerSource::from_str(&source).ok_or_else(|| {
|| { ErrorKind::InputError(format!(
ErrorKind::InputError(format!( "Unknown server source {source}"
"Unknown server source {source}" ))
)) })?,
},
)?,
excluded_synced_server_id, excluded_synced_server_id,
data: nbt_from_bytes(nbt)?, data: nbt_from_bytes(nbt)?,
position, position,
@@ -289,13 +287,11 @@ pub(super) async fn load_projection_entries(
let position: i64 = row.get("position"); let position: i64 = row.get("position");
Ok(ProjectionEntry { Ok(ProjectionEntry {
id: server_id, id: server_id,
owner: ProjectionOwner::from_str(&owner).ok_or_else( owner: ProjectionOwner::from_str(&owner).ok_or_else(|| {
|| { ErrorKind::InputError(format!(
ErrorKind::InputError(format!( "Unknown server projection owner {owner}"
"Unknown server projection owner {owner}" ))
)) })?,
},
)?,
data: nbt_from_bytes(nbt)?, data: nbt_from_bytes(nbt)?,
position, position,
}) })
-1
View File
@@ -61,7 +61,6 @@ pub(crate) async fn read_game_version_metadata_from_jar(
Ok(None) Ok(None)
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
use winreg::{RegKey, enums::HKEY_CURRENT_USER}; use winreg::{RegKey, enums::HKEY_CURRENT_USER};
+1 -1
View File
@@ -65,4 +65,4 @@ pub(crate) async fn load_game_option_preferences(
pool: &SqlitePool, pool: &SqlitePool,
) -> crate::Result<HashMap<String, StoredPreference>> { ) -> crate::Result<HashMap<String, StoredPreference>> {
Ok(sqlx::query("SELECT option_id, enabled, revision FROM synced_game_option_preferences").fetch_all(pool).await?.into_iter().map(|r| { let option_id: String = r.get("option_id"); let enabled: bool = r.get("enabled"); let revision: i64 = r.get("revision"); (option_id, StoredPreference { enabled, revision: revision.max(0) as u64 }) }).collect()) Ok(sqlx::query("SELECT option_id, enabled, revision FROM synced_game_option_preferences").fetch_all(pool).await?.into_iter().map(|r| { let option_id: String = r.get("option_id"); let enabled: bool = r.get("enabled"); let revision: i64 = r.get("revision"); (option_id, StoredPreference { enabled, revision: revision.max(0) as u64 }) }).collect())
} }
@@ -49,4 +49,4 @@ pub(crate) struct StoredOption {
pub(crate) struct StoredPreference { pub(crate) struct StoredPreference {
pub(crate) enabled: bool, pub(crate) enabled: bool,
pub(crate) revision: u64, pub(crate) revision: u64,
} }
@@ -110,7 +110,6 @@ pub struct InstanceSyncedOptions {
pub data_packs: bool, pub data_packs: bool,
} }
/// The set of per-instance synchronization features. Mirrors the Axolotl /// The set of per-instance synchronization features. Mirrors the Axolotl
/// `SyncedOption` enum, including its string keys used by the /// `SyncedOption` enum, including its string keys used by the
/// `instance_sync_preferences` / `sync_feature_settings` tables. /// `instance_sync_preferences` / `sync_feature_settings` tables.
@@ -66,4 +66,4 @@ fn unknown_value(kind: &str, value: &str) -> crate::Error {
crate::ErrorKind::InputError(format!("Unknown {kind} {value}")).into() crate::ErrorKind::InputError(format!("Unknown {kind} {value}")).into()
} }
mod game_options; mod game_options;
pub use self::game_options::*; pub use self::game_options::*;