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
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ jobs:
libgtk-3-dev
- uses: Swatinem/rust-cache@v2
with:
workspaces: "gui/src-tauri -> target"
- name: Clippy + build GUI
workspaces: |
gui/src-tauri -> target
. -> target
# The setup ships the CLI next to the app (bundle.externalBin); tauri-build
# wants that file before it builds anything.
- name: Build the CLI sidecar
run: node gui/src-tauri/scripts/build-cli.mjs
- name: Clippy + build + test GUI
working-directory: gui/src-tauri
run: |
cargo clippy --all-targets -- -D warnings
cargo build --release
cargo test --release
# The UI's pure helpers (formatting, breadcrumbs, treemap layout, diff
# indexing) are plain JS with Node unit tests; no npm install needed.
- name: UI unit tests
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ jobs:
libgtk-3-dev
- uses: Swatinem/rust-cache@v2
with:
workspaces: "gui/src-tauri -> target"
workspaces: |
gui/src-tauri -> target
. -> target

- name: Install tauri-cli
run: cargo install tauri-cli --version "^2.0" --locked

# beforeBuildCommand builds the CLI for the same target first; every
# bundle carries it (bundle.externalBin).
- name: Build GUI bundles
working-directory: gui/src-tauri
run: cargo tauri build ${{ matrix.target != '' && format('--target {0}', matrix.target) || '' }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
node_modules/
dist/
src-tauri/target/
# The CLI sidecar, built by gui/src-tauri/scripts/build-cli.mjs
gui/src-tauri/binaries/

# OS / editor cruft
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude = ["gui"]
resolver = "2"

[workspace.package]
version = "0.11.0"
version = "0.11.1"
edition = "2021"
license = "MIT"
authors = ["kingchenc"]
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ Find where your space went, hunt down byte-identical duplicates, and reclaim the

## Install

The desktop app's installers bring the `diskghost` CLI along, so one install
gives you both, and updating the app updates the CLI:

- **Windows setup (`*-setup.exe`)**: the CLI sits next to the app and its
folder goes on your user PATH (removed again on uninstall). Open a new
terminal and `diskghost` works.
- **Windows MSI**: the same, installed for all users, on the system PATH.
- **Linux `.deb` / `.rpm`**: `/usr/bin/diskghost`.
- **macOS `.dmg`, AppImage**: inside the app bundle, not on the PATH; use one of
the ways below.

The CLI on its own:

```bash
# Install the `diskghost` command globally, straight from GitHub (no crates.io):
cargo install --git https://github.com/kingchenc/diskghost diskghost-cli
Expand Down Expand Up @@ -187,6 +200,10 @@ cargo tauri dev # run the app
cargo tauri build # bundle an installer
```

Both first build the CLI that the installers carry (`scripts/build-cli.mjs`,
needs Node). A plain `cargo build` / `cargo clippy` here needs that file too:
run `node scripts/build-cli.mjs` once before.

## Why it's fast — and correct

- Parallel directory walk on a thread pool per scan; a **single pass** counts
Expand Down
4 changes: 2 additions & 2 deletions gui/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 gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[package]
name = "diskghost-gui"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
license = "MIT"
description = "Diskghost desktop GUI (Tauri) — modern disk usage & duplicate finder."
Expand Down
32 changes: 32 additions & 0 deletions gui/src-tauri/scripts/build-cli.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Build the `diskghost` CLI and put it where Tauri looks for the sidecar
// (`bundle.externalBin`): binaries/diskghost-<target triple>[.exe]. Runs as
// beforeBuildCommand / beforeDevCommand; run it by hand before a plain
// `cargo build` here (tauri-build refuses to build without the file).
import { execFileSync } from "node:child_process";
import { copyFileSync, mkdirSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const tauriDir = join(dirname(fileURLToPath(import.meta.url)), "..");
const root = join(tauriDir, "..", "..");

// Tauri passes the target it builds for; otherwise build for this machine.
const triple =
process.env.TAURI_ENV_TARGET_TRIPLE ||
/^host: (\S+)$/m.exec(execFileSync("rustc", ["-vV"], { encoding: "utf8" }))[1];
const debug = process.env.TAURI_ENV_DEBUG === "true";
const profile = debug ? "debug" : "release";

const args = ["build", "-p", "diskghost-cli", "--target", triple];
if (!debug) args.push("--release");
execFileSync("cargo", args, { cwd: root, stdio: "inherit" });

const ext = triple.includes("windows") ? ".exe" : "";
const targetDir = process.env.CARGO_TARGET_DIR || join(root, "target");
const outDir = join(tauriDir, "binaries");
mkdirSync(outDir, { recursive: true });
copyFileSync(
join(targetDir, triple, profile, `diskghost${ext}`),
join(outDir, `diskghost-${triple}${ext}`),
);
console.log(`CLI sidecar: binaries/diskghost-${triple}${ext} (${profile})`);
12 changes: 12 additions & 0 deletions gui/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tauri::{Emitter, LogicalSize, Manager};
use tauri_plugin_dialog::DialogExt;

mod helper;
mod path_env;

/// Sub-folders shown inside each folder on the map's second level.
const NESTED_PER_FOLDER: usize = 12;
Expand Down Expand Up @@ -949,6 +950,17 @@ fn main() {
helper::serve(Path::new(&args[2]), &args[3]);
return;
}
// Run by the Windows setup: the CLI next to the app goes on/off the PATH.
if args.len() == 2 && (args[1] == "--add-to-path" || args[1] == "--remove-from-path") {
let code = match path_env::update(args[1] == "--add-to-path") {
Ok(()) => 0,
Err(e) => {
eprintln!("error: {e}");
1
}
};
std::process::exit(code);
}
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.setup(|app| {
Expand Down
Loading
Loading