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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ A Windows desktop app for building and maintaining Minecraft modpacks. It create
projects and installs real mods from Modrinth, with every change reviewed before it is applied.
Awake Launcher is not required.

> **What's new in 1.3.1:** see [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md).
> **What's new in 1.3.3:** see [docs/releases/v1.3.3.md](docs/releases/v1.3.3.md).

**Version 1.3.1 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only**
**Version 1.3.3 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only**

## Install

1. Download `Awake-Modpack-Manager-v1.3.1-Windows-x64-Setup.exe` from the
1. Download `Awake-Modpack-Manager-v1.3.3-Windows-x64-Setup.exe` from the
[latest release](https://github.com/awakenginexe/Awake-Modpack-Manager/releases/latest).
2. Optional: check it against `SHA256SUMS.txt` from the same release
(`Get-FileHash .\Awake-Modpack-Manager-v1.3.1-Windows-x64-Setup.exe`).
(`Get-FileHash .\Awake-Modpack-Manager-v1.3.3-Windows-x64-Setup.exe`).
3. Run the installer. It installs for your Windows user only (no administrator rights) into
`%LOCALAPPDATA%\Awake Modpack Manager`.
The installer is **not code-signed** yet, so Windows SmartScreen may warn that it is from an
Expand Down
9 changes: 5 additions & 4 deletions docs/HANDOFF.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Development checkpoint: Manager 1.3.1 and Native Core 0.4.2
# Development checkpoint: Manager 1.3.3 and Native Core 0.4.2

Unreleased until the owner approves the pull request and tags `v1.3.1`.
Unreleased until the owner approves the pull request and tags `v1.3.3`.

## Where things are

- Manager: branch `release/1.3.1`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`.
- Manager: branch `release/1.3.3`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`.
- Native Core: Awake Launcher branch `release/3.2.2`. `.github/workflows/native-core-package.yml` builds it with the recorded toolchain and commits a delivery under `native-core/redistribution/<commit12>/`. `scripts/helper-pin.json` pins that delivery.
- Release: pushing a version tag runs `.github/workflows/awake-beta.yml`, which builds, verifies, assembles every asset and publishes the release. `SHA256SUMS.txt` is required by in-app updates.

## Architecture added in 0.3.0

- `src-tauri/src/providers.rs`: five modpack catalogs, pack downloads, batched project metadata and update lookups. The CurseForge key stays in the host and the helper's environment.
- `src-tauri/src/updater.rs`: GitHub release check and checksum-verified installer run.
- `src-tauri/src/desktop.rs`: content folders of a project or managed Launcher instance (list a folder, edit a text file, view an image (1.3.1), add files, Recycle Bin), shell open. Mods are never touched here.
- `src-tauri/src/desktop.rs`: content folders of a project or managed Launcher instance (list a folder, edit a text file, view an image (1.3.1), add files, Recycle Bin), shell open. Mods are not changed here, except `fix_modified` (1.3.3): on the user's request it puts back the exact file the helper recorded for a mod changed outside the Manager (hash-checked download, changed file backed up), or drops that record.
- `src-tauri/src/content.rs` (1.3.0): resource pack and shader search, versions and direct, checksum-verified install into `resourcepacks` / `shaderpacks`.
- `src-tauri/src/manual.rs` (1.3.2): restricted CurseForge mods. Names the exact file and its download page, then moves the SHA-1-matching jar from Downloads (or a picked file) into `mods`. The helper lists it as a manual file.
- `HelperClient.installPack`: one local operation over fetch, upload, create, prepare and apply. A failure removes the created project.
- FTB versions become a generated `.mrpack` manifest; ATLauncher and Technic become a CurseForge-format archive of overrides.
- Native Core: `workspaces.delete`, `workspaces.rename`, `imports.prepare` with `packAuthoritative`, `removeInventoryIds` and `allowLoaderUpdate`, a helper-only hash cache, batched provider reads and parallel downloads.
Expand Down
21 changes: 21 additions & 0 deletions docs/releases/v1.3.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Awake Modpack Manager 1.3.2

Works with **Awake Launcher 3.2.2**. No Launcher update is needed.

## Added

- **Mods that can only be downloaded from the CurseForge website.** Some authors turn off third-party distribution, and checking a plan with one of their mods used to stop at "CurseForge project does not allow third-party distribution". The Review page now lists those mods with an **Open download page** button: CurseForge starts the download after a few seconds, the Manager notices the file in your Downloads folder, moves it into the pack and takes the install out of the draft. Check the plan again for the rest of the draft.
- **Open all** opens every download page at once when there is more than one.
- **Choose downloaded file…** is for a download that went somewhere else, or a Downloads folder that is not in its usual place.

## How it behaves

- A file is taken only if its SHA-1 is the one CurseForge lists for that exact version, whatever the browser named it. Anything else in Downloads is left alone, and so is a download still in progress.
- Nothing in `mods` is overwritten. If another file already has the name, the download stays where it is.
- The Downloads folder is only looked at while the Review page is waiting for one of these files.
- A mod added this way shows as a manually added file: the helper does not track it, so the Manager does not offer updates for it. A CurseForge export still recognises it by its fingerprint.
- Only mods in your draft are offered. A restricted mod that is pulled in as a dependency still stops the check; add it to the draft yourself to get its download button.

## Not verified on a real machine yet

The demo data and the automated tests cover the Review page, and the host's file matching and move have their own tests. Still unverified: the whole flow in the desktop app against CurseForge and a real Downloads folder.
18 changes: 18 additions & 0 deletions docs/releases/v1.3.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Awake Modpack Manager 1.3.3

Works with **Awake Launcher 3.2.2**. No Launcher update is needed.

## Fixed

- **Changes kept getting rolled back with "Applied metadata did not verify."** After applying, the helper re-checks every tracked mod, not only the ones that changed. If any mod's jar no longer matched what the helper recorded, for example because a different build of that mod was copied into the pack, every apply was rolled back, even one that only installed an unrelated mod. Review & apply now warns about this before you apply. It lists the mods changed outside the Manager and offers two fixes:
- **Restore originals** downloads the recorded file again and puts it back only if its hashes match the record exactly. Your changed file is copied first to `%LOCALAPPDATA%\AwakeModpackManager\policy-backups\`. If the download doesn't match, nothing changes.
- **Keep my files** leaves your file as it is and stops tracking it. Use this when a pack ships its own build of a mod on purpose. The Manager won't offer updates for that mod any more.

## Changed

- **History lists the newest operation first.**
- **History shows which mods each change touched:** installed, removed, updated (old → new version), enabled or disabled. A change that failed or was rolled back is labelled as not applied. Long lists start folded. The list is kept on this computer for the last 200 applies. Changes made before 1.3.3 have no list, because the helper never recorded mod names.

## Not verified on a real machine yet

The demo data and the automated tests cover both pages, and the host's restore and keep logic has its own tests. Still unverified: Restore originals in the desktop app against a real instance and Modrinth.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "awake-modpack-manager",
"private": true,
"version": "1.3.1",
"version": "1.3.3",
"license": "GPL-3.0-only",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awake-modpack-manager"
version = "1.3.1"
version = "1.3.3"
description = "Awake Modpack Manager desktop host"
license = "GPL-3.0-only"
repository = "https://github.com/awakenginexe/Awake-Modpack-Manager"
Expand Down
115 changes: 113 additions & 2 deletions src-tauri/src/desktop.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! Desktop integration: opening folders and links with the shell, and managing the non-mod content
//! (config, scripts, resource packs, shaders...) of a project or of a Launcher instance managed here.
//!
//! Mods are never touched here: they belong to the native helper's reviewed transactions. Everything
//! Mods are never changed here: they belong to the native helper's reviewed transactions. The one exception,
//! `fix_modified`, only puts back the exact file the helper recorded, after the user asked for it. Everything
//! else stays inside one of the content folders below, never follows a link out of it, and is only
//! ever removed to the Recycle Bin.

use crate::helper::manager_data_dir;
use crate::providers::{err, HostResult};
use crate::providers::{err, HostError, HostResult};
use serde::Serialize;
use serde_json::Value;
use std::collections::HashSet;
Expand Down Expand Up @@ -344,6 +345,77 @@ pub async fn workspace_forget_missing(workspace: String) -> HostResult<Vec<Strin
.unwrap_or_else(|e| err("internal", e.to_string()))
}

fn file_hash<D: sha2::Digest + std::io::Write>(path: &Path) -> HostResult<String> {
let mut digest = D::new();
std::io::copy(&mut fs::File::open(path).or_else(|e| err("io", e.to_string()))?, &mut digest).or_else(|e| err("io", e.to_string()))?;
Ok(crate::providers::hex(&digest.finalize()))
}

/// Tracked mods whose bytes no longer match the helper's record, which makes the helper roll back every apply.
/// `restore` puts back the recorded file, only once a fresh download hashes exactly as recorded, after copying the
/// changed file to `backup_dir`. Otherwise the record is dropped and the changed file stays as an untracked mod.
/// Returns the file names fixed; a file that matches its record already is left alone.
pub fn fix_modified(game: &Path, backup_dir: &Path, files: &[String], restore: bool, fetch: impl Fn(&str, &Path, u64) -> HostResult<()>) -> HostResult<Vec<String>> {
use sha2::{Sha256, Sha512};
let path = game.parent().unwrap_or(game).join(".awake-integration").join("policies.json");
let io = |e: std::io::Error| HostError { code: "io", message: e.to_string() };
let mut doc: Value = serde_json::from_str(&fs::read_to_string(&path).map_err(io)?).or_else(|_| err("invalid", "This project's mod records are damaged."))?;
let before = doc.clone();
let mods = game.join("mods");
let wanted: HashSet<String> = files.iter().map(|f| f.to_lowercase().trim_end_matches(".disabled").to_string()).collect();
let Some(projects) = doc["projects"].as_object_mut() else { return err("invalid", "This project's mod records are damaged.") };
let keys: Vec<String> = projects.iter().filter(|(_, e)| wanted.contains(&e["fileName"].as_str().unwrap_or_default().to_lowercase())).map(|(k, _)| k.clone()).collect();
let mut fixed = vec![];
for key in keys {
let entry = projects[&key].clone();
let name = entry["fileName"].as_str().unwrap_or_default().to_string();
let Some(jar) = [name.clone(), format!("{name}.disabled")].into_iter().map(|n| mods.join(n)).find(|p| p.is_file()) else { continue };
let recorded = entry["sha256"].as_str().unwrap_or_default();
if file_hash::<Sha256>(&jar)? == recorded {
continue;
}
if restore {
let artifact = &entry["version"]["files"][0];
let (Some(url), Some(sha512)) = (artifact["url"].as_str(), artifact["sha512"].as_str()) else {
return err("unsupported", format!("{name} cannot be downloaded again here. Keep your file instead."));
};
let size = artifact["size"].as_u64().or_else(|| artifact["size"].as_str()?.parse().ok()).unwrap_or(1 << 30);
let tmp = mods.join(format!(".{name}.awake-restore"));
let checked = fetch(url, &tmp, size).and_then(|_| {
if file_hash::<Sha512>(&tmp)? == sha512 && file_hash::<Sha256>(&tmp)? == recorded { Ok(()) } else { err("integrity", format!("The download of {name} did not match its record; nothing was changed.")) }
});
if let Err(e) = checked {
let _ = fs::remove_file(&tmp);
return Err(e);
}
fs::create_dir_all(backup_dir).map_err(io)?;
fs::copy(&jar, backup_dir.join(jar.file_name().unwrap_or_default())).map_err(io)?;
fs::rename(&tmp, &jar).map_err(io)?;
} else {
projects.remove(&key);
}
fixed.push(name);
}
if !restore && !fixed.is_empty() {
fs::create_dir_all(backup_dir).map_err(io)?;
fs::write(backup_dir.join("policies.json"), before.to_string()).map_err(io)?;
crate::files::write_atomic(&path, doc.to_string().as_bytes(), false).or_else(|m| err("io", m))?;
}
Ok(fixed)
}

#[tauri::command]
pub async fn workspace_fix_modified(workspace: String, files: Vec<String>, restore: bool) -> HostResult<Vec<String>> {
tauri::async_runtime::spawn_blocking(move || {
let game = crate::export::game_folder(&workspace)?;
let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
let backup = manager_data_dir().or_else(|m| err("io", m))?.join("policy-backups").join(format!("{workspace}-{stamp}"));
fix_modified(&game, &backup, &files, restore, |url, to, limit| crate::providers::download(None, url, &[], to, limit, |_| {}))
})
.await
.unwrap_or_else(|e| err("internal", e.to_string()))
}

#[cfg(windows)]
fn shell_open(target: &str) -> HostResult<()> {
use std::os::windows::ffi::OsStrExt;
Expand Down Expand Up @@ -574,6 +646,45 @@ mod tests {
fs::remove_dir_all(&root).unwrap();
}

#[test]
fn fixing_modified_mods_restores_only_a_verified_download_or_forgets_the_record() {
use sha2::{Digest, Sha256, Sha512};
let root = std::env::temp_dir().join(format!("awake-mm-fixmod-{}", std::process::id()));
let _ = fs::remove_dir_all(&root);
let (game, policies, backup) = (root.join("minecraft"), root.join(".awake-integration").join("policies.json"), root.join("backups"));
fs::create_dir_all(game.join("mods")).unwrap();
fs::create_dir_all(policies.parent().unwrap()).unwrap();
let good = b"original jar";
let h = |b: &[u8]| (crate::providers::hex(&Sha256::digest(b)), crate::providers::hex(&Sha512::digest(b)));
let (s256, s512) = h(good);
let entry = |file: &str| serde_json::json!({"fileName": file, "sha256": s256, "version": {"files": [{"url": "https://x/a", "sha512": s512, "size": good.len()}]}});
let doc = serde_json::json!({"projects": {"a": entry("a.jar"), "b": entry("b.jar"), "ok": entry("ok.jar")}});
fs::write(&policies, doc.to_string()).unwrap();
fs::write(game.join("mods").join("a.jar"), "changed").unwrap();
fs::write(game.join("mods").join("b.jar.disabled"), "changed").unwrap();
fs::write(game.join("mods").join("ok.jar"), good).unwrap();
let names = |v: &[&str]| v.iter().map(|s| s.to_string()).collect::<Vec<_>>();

// A download that does not hash as recorded changes nothing and leaves no temp file.
let bad = |_: &str, to: &Path, _: u64| { fs::write(to, "tampered").unwrap(); Ok(()) };
assert!(fix_modified(&game, &backup, &names(&["a.jar"]), true, bad).is_err());
assert_eq!(fs::read(game.join("mods").join("a.jar")).unwrap(), b"changed");
assert_eq!(fs::read_dir(game.join("mods")).unwrap().count(), 3);

let fetch = |_: &str, to: &Path, _: u64| { fs::write(to, good).unwrap(); Ok(()) };
assert_eq!(fix_modified(&game, &backup, &names(&["a.jar", "ok.jar"]), true, fetch).unwrap(), ["a.jar"]);
assert_eq!(fs::read(game.join("mods").join("a.jar")).unwrap(), good);
assert_eq!(fs::read(backup.join("a.jar")).unwrap(), b"changed");

// Keeping the changed file drops only its record; the file stays.
assert_eq!(fix_modified(&game, &backup, &names(&["b.jar.disabled"]), false, fetch).unwrap(), ["b.jar"]);
let after: Value = serde_json::from_str(&fs::read_to_string(&policies).unwrap()).unwrap();
assert!(after["projects"].get("b").is_none() && after["projects"].get("a").is_some());
assert_eq!(fs::read(game.join("mods").join("b.jar.disabled")).unwrap(), b"changed");
assert_eq!(serde_json::from_str::<Value>(&fs::read_to_string(backup.join("policies.json")).unwrap()).unwrap(), doc);
fs::remove_dir_all(&root).unwrap();
}

#[test]
fn workspaces_are_named_by_uuid_only() {
assert!(is_uuid("0f1e2d3c-4b5a-4968-8778-695a4b3c2d1e"));
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod desktop;
mod discovery;
mod files;
mod helper;
mod manual;
mod pipe;
mod profile_access;
mod providers;
Expand Down Expand Up @@ -114,7 +115,10 @@ pub fn run() {
content::content_search,
content::content_versions,
content::content_install,
manual::manual_sources,
manual::manual_claim,
desktop::workspace_forget_missing,
desktop::workspace_fix_modified,
desktop::workspace_open,
desktop::open_url,
desktop::app_info,
Expand Down
Loading
Loading