Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions migrations/021_mod_guid.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE installed_mods ADD COLUMN guid TEXT;
7 changes: 7 additions & 0 deletions src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ pub fn restore_mod_backup(
version,
"forge",
None,
None,
)?
}
};
Expand Down Expand Up @@ -570,6 +571,7 @@ pub fn restore_full_backup(
&mm.version,
"forge",
None,
None,
)?;

restore_manifest_files(
Expand Down Expand Up @@ -814,6 +816,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();
db.insert_file(
Expand Down Expand Up @@ -924,6 +927,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();
let mut config = crate::config::Config::default();
Expand Down Expand Up @@ -1043,6 +1047,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand Down Expand Up @@ -1096,6 +1101,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();
db.insert_file(
Expand All @@ -1114,6 +1120,7 @@ mod tests {
"2.0.0",
"forge",
None,
None,
)
.unwrap();
db.insert_file(
Expand Down
1 change: 1 addition & 0 deletions src/cli/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ pub async fn drain_all(ctx: &CliContext) -> Result<usize> {
archive_path: archive,
source,
source_url: op.source_url.as_deref(),
guid: None,
},
) {
Ok(db_id) => db_id,
Expand Down
11 changes: 11 additions & 0 deletions src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ async fn install_deps(ctx: &CliContext, deps: &[PendingInstall]) -> Result<()> {
name: &dep.name,
slug: dep_mod.slug.as_deref(),
version: &dep.version,
guid: dep_mod.guid.as_deref(),
},
)
.await?;
Expand Down Expand Up @@ -546,6 +547,7 @@ async fn install_main_mod(
name: &forge_mod.name,
slug: forge_mod.slug.as_deref(),
version: &selected_version.version,
guid: forge_mod.guid.as_deref(),
},
)
.await
Expand Down Expand Up @@ -591,6 +593,7 @@ pub struct ModInstallParams<'a> {
pub name: &'a str,
pub slug: Option<&'a str>,
pub version: &'a str,
pub guid: Option<&'a str>,
}

/// Download a mod archive from Forge, extract it, and record it in the database.
Expand All @@ -615,6 +618,7 @@ pub async fn download_and_install(
name,
slug,
version,
guid,
} = params;

let tmp_dir = tempfile::tempdir().context("failed to create temp directory")?;
Expand All @@ -640,6 +644,7 @@ pub async fn download_and_install(
archive_path: &archive_path,
source: crate::ops::ModSource::Forge,
source_url: None,
guid: *guid,
})?;

let file_count = db.get_files_for_mod(db_id)?.len();
Expand Down Expand Up @@ -667,6 +672,7 @@ pub async fn download_and_install_with_arc(
name,
slug,
version,
guid,
} = params;

let tmp_dir = tempfile::tempdir().context("failed to create temp directory")?;
Expand Down Expand Up @@ -694,6 +700,7 @@ pub async fn download_and_install_with_arc(
archive_path: &archive_path,
source: crate::ops::ModSource::Forge,
source_url: None,
guid: *guid,
})?
};

Expand Down Expand Up @@ -841,6 +848,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand Down Expand Up @@ -981,6 +989,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand Down Expand Up @@ -1166,6 +1175,7 @@ async fn install_from_url(
archive_path: &archive_path,
source: crate::ops::ModSource::Url,
source_url: Some(url),
guid: None,
})?;

println!("\n{mod_name} installed successfully (ID: {db_id}).");
Expand Down Expand Up @@ -1217,6 +1227,7 @@ async fn install_from_file(
archive_path: &archive_path,
source: crate::ops::ModSource::File,
source_url: None,
guid: None,
})?;

println!("\n{mod_name} installed successfully (ID: {db_id}).");
Expand Down
1 change: 1 addition & 0 deletions src/cli/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ mod tests {
source: "forge".to_string(),
source_url: None,
group_id: None,
guid: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/cli/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.expect("insert mod");
db.insert_file(
Expand Down
59 changes: 54 additions & 5 deletions src/cli/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand All @@ -294,6 +295,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand All @@ -314,6 +316,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();

Expand Down Expand Up @@ -351,6 +354,7 @@ mod tests {
"1.0.0",
"forge",
None,
None,
)
.unwrap();
ctx.db
Expand Down Expand Up @@ -379,11 +383,29 @@ mod tests {

let mod_c = ctx
.db
.insert_mod(Some(100), Some(200), "ModC", None, "1.0.0", "forge", None)
.insert_mod(
Some(100),
Some(200),
"ModC",
None,
"1.0.0",
"forge",
None,
None,
)
.unwrap();
let mod_b = ctx
.db
.insert_mod(Some(101), Some(201), "ModB", None, "1.0.0", "forge", None)
.insert_mod(
Some(101),
Some(201),
"ModB",
None,
"1.0.0",
"forge",
None,
None,
)
.unwrap();
// B depends on C
ctx.db
Expand All @@ -409,15 +431,42 @@ mod tests {

let mod_c = ctx
.db
.insert_mod(Some(100), Some(200), "ModC", None, "1.0.0", "forge", None)
.insert_mod(
Some(100),
Some(200),
"ModC",
None,
"1.0.0",
"forge",
None,
None,
)
.unwrap();
let mod_b = ctx
.db
.insert_mod(Some(101), Some(201), "ModB", None, "1.0.0", "forge", None)
.insert_mod(
Some(101),
Some(201),
"ModB",
None,
"1.0.0",
"forge",
None,
None,
)
.unwrap();
let mod_a = ctx
.db
.insert_mod(Some(102), Some(202), "ModA", None, "1.0.0", "forge", None)
.insert_mod(
Some(102),
Some(202),
"ModA",
None,
"1.0.0",
"forge",
None,
None,
)
.unwrap();
// A depends on B, B depends on C
ctx.db
Expand Down
1 change: 1 addition & 0 deletions src/cli/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ async fn install_from_forge(
name: &forge_mod.name,
slug: forge_mod.slug.as_deref(),
version: version_str,
guid: forge_mod.guid.as_deref(),
},
)
.await?;
Expand Down
1 change: 1 addition & 0 deletions src/cli/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ mod tests {
source: "forge".to_string(),
source_url: None,
group_id: None,
guid: None,
}];

assert_eq!(mod_name_for_id(&mods, 100), "TestMod");
Expand Down
2 changes: 1 addition & 1 deletion src/config_mgmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod tests {
let mgr = ConfigManager::new(&QumaDirs::from_legacy(spt_dir.to_path_buf()));
let db = crate::db::Database::open_in_memory().unwrap();
// Insert a mod matching the directory name
db.insert_mod(None, None, "TestMod", None, "1.0.0", "manual", None)
db.insert_mod(None, None, "TestMod", None, "1.0.0", "manual", None, None)
.unwrap();

let configs = mgr.discover_configs(&db).unwrap();
Expand Down
Loading
Loading