Keep unsupported Reborn realms out of experimental portable transfers

This commit is contained in:
Дмитрий committed 2026-10-21 22:54:54 +05:00
1 parent 16c3b1ec57
commit 5012f7b104
7 files changed
+16 -12

No files matched your search

@@ -35,7 +35,7 @@ fn realm_error(e: crate::Error) -> PortableError {
}
fn coa_only(db: &Db) -> Result<()> {
if ruleset_of(db) != Ruleset::Coa {
if ruleset_of(db)? != Ruleset::Coa {
return Err(PortableError::Invalid(
"collections are carried for CoA realms only (Wildcard transfer is disabled)".into(),
));
+2 -2
View File
@@ -200,7 +200,7 @@ pub fn preflight(
opts: &ImportOptions,
) -> Result<PreflightReport> {
let mut report = PreflightReport::default();
let realm_ruleset = ruleset_of(db);
let realm_ruleset = ruleset_of(db)?;
if model.ruleset != realm_ruleset {
report.problems.push(ImportProblem::WrongRuleset {
character: model.ruleset,
@@ -452,7 +452,7 @@ pub fn import_character_in_session(
let plan = match build_plan(
&model,
&PlanContext {
ruleset: ruleset_of(db),
ruleset: ruleset_of(db)?,
account,
revision: record.revision,
nonce: ticket.nonce,
+6 -5
View File
@@ -51,10 +51,11 @@ pub use reconcile::{
pub use script::SchemaProbe;
/// The ruleset a database belongs to is decided by which realm profile it is (`realms::Mode`), never by the caller.
pub fn ruleset_of(db: &Db) -> Ruleset {
pub fn ruleset_of(db: &Db) -> Result<Ruleset> {
match db.realm() {
Mode::Coa => Ruleset::Coa,
Mode::Wildcard => Ruleset::Wildcard,
Mode::Coa => Ok(Ruleset::Coa),
Mode::Wildcard => Ok(Ruleset::Wildcard),
Mode::Reborn => Err(PortableError::Invalid("Portable characters are not supported on Warcraft Reborn realms yet.".into())),
}
}
@@ -216,7 +217,7 @@ pub fn export_character_with_pets(
export::build(
&raw,
&ExportRequest {
ruleset: ruleset_of(db),
ruleset: ruleset_of(db)?,
local_guid,
character_id,
prior_items,
@@ -240,7 +241,7 @@ pub fn read_session_character(
export::build(
&raw,
&ExportRequest {
ruleset: ruleset_of(db),
ruleset: ruleset_of(db)?,
local_guid,
character_id: Some(character_id),
prior_items,
@@ -92,7 +92,7 @@ pub fn assemble(
let mut extension_realm = NoRealm { probe };
let extensions = registry.supported_on(&mut extension_realm);
let content = ContentProfile {
ruleset: ruleset_of(db),
ruleset: ruleset_of(db)?,
character_formats: ContentProfile::manager_formats(),
online_import_job_formats: core
.map(|c| c.portable.job_formats.clone())
@@ -738,8 +738,9 @@ fn update_inner(
merged
};
let schema = probe(db)?;
let ruleset = ruleset_of(db)?;
let context = |nonce| UpdateContext {
ruleset: ruleset_of(db),
ruleset,
local_guid: guid,
revision: record.revision,
nonce,
+3 -1
View File
@@ -728,8 +728,10 @@ fn the_wildcard_ruleset_uses_its_own_namespace_and_quarantines_wildcard_state()
// the realm profile of a database decides the ruleset, not the caller
let wc_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Wildcard);
let coa_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Coa);
let reborn_db = Db::with_tools(std::path::PathBuf::new(), 1, "root", "x", Mode::Reborn);
assert!(ruleset_of(&reborn_db).is_err());
assert_eq!(
(ruleset_of(&wc_db), ruleset_of(&coa_db)),
(ruleset_of(&wc_db).unwrap(), ruleset_of(&coa_db).unwrap()),
(Ruleset::Wildcard, Ruleset::Coa)
);
assert_eq!(
@@ -1438,7 +1438,7 @@ impl PortableService {
let model = self.host.load_current(character_id)?;
let encoded = super::super::snapshot::encode(&model)?;
let mut collections = BTreeMap::new();
if realm::ruleset_of(&db) == super::super::model::Ruleset::Coa {
if realm::ruleset_of(&db)? == super::super::model::Ruleset::Coa {
if let Some(account) = realm::collections::account_of(&db, local_guid)? {
for kind in ["coa:appearance", "coa:vanity"] {
if let Ok(set) = realm::collections::read_set(&db, account, kind) {