wows-data-mgr 0.20.0

Download and manage World of Warships game data for offline replay analysis
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
use clap::Parser;
use clap::Subcommand;
use rootcause::prelude::*;
use std::path::PathBuf;

mod detect;
mod download;

use wows_data_mgr::dump;
use wows_data_mgr::manifest;
use wows_data_mgr::registry;

/// Corrupt objects described in full per build before the rest are summarised.
/// A build can reference dozens of them and each message names files.
const NAMED_CORRUPT_OBJECTS: usize = 3;

#[derive(Parser)]
#[command(name = "wows-data-mgr", about = "Download and manage World of Warships game data")]
struct Args {
    /// Override the game data directory (default: game_data/ in repo root)
    #[arg(long, global = true)]
    data_dir: Option<PathBuf>,

    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Download game data for a specific version via DepotDownloader
    Download {
        /// Download the latest known version
        #[arg(long, conflicts_with_all = &["build", "version"])]
        latest: bool,

        /// Download by build number (e.g. 11965230)
        #[arg(long, conflicts_with_all = &["latest", "version"])]
        build: Option<u32>,

        /// Download by version string (e.g. 15.1 or 15.1.0)
        #[arg(long, conflicts_with_all = &["latest", "build"])]
        version: Option<String>,

        /// Force re-download even if already present
        #[arg(long)]
        force: bool,

        /// Steam username (otherwise reads from .steam-user)
        #[arg(long)]
        username: Option<String>,
    },

    /// List known game versions and their download status
    List,

    /// Detect game versions from downloaded/installed data
    Detect {
        /// Path to scan (default: game_data/builds/)
        path: Option<PathBuf>,
    },

    /// Dump renderer-required game data to a directory for offline use
    DumpRendererData {
        /// Dump for the latest available build
        #[arg(long, conflicts_with_all = &["build", "version"])]
        latest: bool,

        /// Dump by build number (e.g. 11965230)
        #[arg(long, conflicts_with_all = &["latest", "version"])]
        build: Option<u32>,

        /// Dump by version string (e.g. 15.1 or 15.1.0)
        #[arg(long, conflicts_with_all = &["latest", "build"])]
        version: Option<String>,

        /// Output directory (a subdirectory named <version>_<build> will be created)
        #[arg(short, long)]
        output: PathBuf,

        /// Overwrite existing dump for this build
        #[arg(long)]
        force: bool,

        /// Dump directly from this game install directory, skipping the
        /// version manifest and registry. Use together with --build.
        #[arg(long, conflicts_with_all = &["latest", "version"])]
        game_dir: Option<PathBuf>,
    },

    /// Remove a previously dumped build, cleaning up deduplicated storage
    Remove {
        /// Remove by build number
        #[arg(long, conflicts_with = "version")]
        build: Option<u32>,

        /// Remove all builds matching a version string (e.g. 15.1 or 15.1.0)
        #[arg(long, conflicts_with = "build")]
        version: Option<String>,

        /// Directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,
    },

    /// Regenerate derived artifacts (rkyv blob, compressed copies) for dumped
    /// builds, deduplicate them into content-addressed storage, then garbage
    /// collect CAS objects no longer referenced by any build. Pass `--no-gc`
    /// to keep orphaned objects around (run `gc` later to reclaim them).
    RefreshDerived {
        /// Directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,

        /// Refresh only this build number (default: all builds)
        #[arg(long)]
        build: Option<u32>,

        /// Skip the automatic post-refresh garbage collection. Orphaned CAS
        /// objects (typically previous versions of replaced rkyv/zst blobs)
        /// stay on disk until `wows-data-mgr gc` runs.
        #[arg(long)]
        no_gc: bool,
    },

    /// Delete content-addressed objects no longer referenced by any dumped
    /// build. This is the only command that removes shared storage.
    Gc {
        /// Directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,
    },

    /// Print the VFS path globs the dump extracts, one per line. Feed these to
    /// `wowsunpack pkgs` to resolve the minimal set of .pkg files to download.
    RequiredPaths,

    /// Add missing assets (maps, and with --with-gui the gui/ dirs) to an
    /// existing build without re-extracting data it already has. Regenerates the
    /// rkyv blob with the current parser. Only needs gui + spaces_* packages on
    /// disk, not the multi-GiB basecontent package.
    CompleteBuild {
        /// Build number to complete (must already exist in builds.toml)
        #[arg(long)]
        build: u32,

        /// Game install directory holding bin/<build>/idx and res_packages
        #[arg(long)]
        game_dir: PathBuf,

        /// Output directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,

        /// Also re-extract the gui/ asset dirs (ribbons, achievements, flags, ...)
        #[arg(long)]
        with_gui: bool,
    },

    /// Fold a legacy `vfs_common/` store into `common/` and relink every build,
    /// healing a dump base where a redump created `common/` while old builds
    /// still reference `vfs_common/`.
    MigrateCas {
        /// Directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,
    },

    /// Verify that every build in a dump base is internally consistent: its
    /// metadata parses and every referenced content object exists in common/,
    /// and with --check-hashes that each object's bytes still hash to its name.
    /// Exits non-zero if any build is broken.
    Verify {
        /// Directory containing dumps (same as dump-renderer-data --output)
        #[arg(short, long)]
        output: PathBuf,

        /// Also check that each reconstructed symlink resolves to a readable file
        #[arg(long)]
        check_links: bool,

        /// Also read every referenced object and check its bytes against its
        /// name, catching content that was rewritten in place
        #[arg(long)]
        check_hashes: bool,
    },

    /// Copy dumped builds from a local source dump base into a destination
    /// (e.g. the toolkit's data cache), deduplicating against content already
    /// present. The offline equivalent of the toolkit's GitHub download, for
    /// testing cache updates without publishing data.
    Update {
        /// Source dump base to copy from (must contain builds.toml and common/)
        #[arg(long)]
        from: PathBuf,

        /// Destination dump base (the toolkit's data cache)
        #[arg(short, long)]
        output: PathBuf,

        /// Copy only the latest build in the source
        #[arg(long, conflicts_with_all = &["build", "version"])]
        latest: bool,

        /// Copy a single build number
        #[arg(long, conflicts_with_all = &["latest", "version"])]
        build: Option<u32>,

        /// Copy all builds matching a version string (e.g. 15.1 or 15.1.0)
        #[arg(long, conflicts_with_all = &["latest", "build"])]
        version: Option<String>,

        /// Re-copy even if the destination already has the build
        #[arg(long)]
        force: bool,
    },

    /// Register an existing WoWs installation without downloading
    Register {
        /// Register as the "latest" path — always use whatever builds exist here
        #[arg(long, conflicts_with_all = &["version", "build"])]
        latest: bool,

        /// Version string (e.g. 15.1 or 15.1.0)
        #[arg(long, conflicts_with = "build")]
        version: Option<String>,

        /// Build number (e.g. 11965230)
        #[arg(long, conflicts_with = "version")]
        build: Option<u32>,

        /// Path to the WoWs installation directory
        #[arg(long, required = true)]
        path: PathBuf,
    },
}

fn find_repo_root() -> Result<PathBuf, Report> {
    let mut dir = std::env::current_dir()?;
    loop {
        if dir.join("game_versions.toml").exists() {
            return Ok(dir);
        }
        if !dir.pop() {
            bail!("Could not find repo root (no game_versions.toml found in parent directories)");
        }
    }
}

fn resolve_data_dir(args_data_dir: &Option<PathBuf>) -> Result<PathBuf, Report> {
    if let Some(dir) = args_data_dir {
        Ok(dir.clone())
    } else {
        let repo_root = find_repo_root()?;
        Ok(repo_root.join("game_data"))
    }
}

fn main() -> Result<(), Report> {
    tracing_subscriber::fmt()
        .with_target(false)
        .with_writer(std::io::stderr)
        .with_max_level(tracing::Level::INFO)
        .init();

    let args = Args::parse();
    let repo_root = find_repo_root()?;
    let data_dir = resolve_data_dir(&args.data_dir)?;

    // These commands don't need the version manifest, so handle them before
    // loading it (a malformed game_versions.toml must not block them).
    match &args.command {
        Commands::RefreshDerived { output, build, no_gc } => {
            println!("Refreshing derived data...");
            dump::refresh_derived(output, *build)?;
            if !*no_gc {
                println!("Garbage-collecting orphaned CAS objects...");
                dump::gc_cas(output)?;
            } else {
                println!("Skipping garbage collection (--no-gc).");
            }
            return Ok(());
        }
        Commands::Gc { output } => {
            println!("Garbage-collecting orphaned CAS objects...");
            return dump::gc_cas(output);
        }
        Commands::RequiredPaths => {
            for glob in dump::required_path_globs() {
                println!("{glob}");
            }
            return Ok(());
        }
        Commands::CompleteBuild { build, game_dir, output, with_gui } => {
            println!("Completing build {build} from {} (with_gui={with_gui})...", game_dir.display());
            let map_count = dump::complete_build(game_dir, *build, output, *with_gui)?;
            println!("Done: extracted {map_count} map(s) and regenerated derived data.");
            return Ok(());
        }
        Commands::MigrateCas { output } => {
            println!("Merging vfs_common/ into common/ and relinking builds in {}...", output.display());
            let migrated = dump::migrate_cas_dir_name(output)?;
            if migrated {
                println!("Done. Run `verify` to confirm consistency.");
            } else {
                println!("Nothing to migrate (no vfs_common/ present).");
            }
            return Ok(());
        }
        Commands::Verify { output, check_links, check_hashes } => {
            let reports = dump::verify_builds(output, *check_links, *check_hashes)?;
            if reports.is_empty() {
                println!("No builds found in {}", output.display());
                return Ok(());
            }
            let mut broken = 0;
            let mut corrupt_hashes = std::collections::BTreeSet::new();
            for r in &reports {
                if r.is_ok() {
                    println!("  OK   {} ({} objects)", r.dir, r.referenced);
                } else {
                    broken += 1;
                    if r.metadata_unreadable {
                        println!("  FAIL {} - metadata.toml unreadable", r.dir);
                    } else {
                        // Without --check-hashes nothing read the bytes, so
                        // "0 corrupt" would assert an audit that never ran.
                        // That is the reassurance 77 corrupt objects hid
                        // behind for months.
                        let corrupt = if *check_hashes {
                            format!("{} corrupt", r.corrupt_objects.len())
                        } else {
                            "hashes not checked".to_string()
                        };
                        println!(
                            "  FAIL {} - {}/{} objects missing, {corrupt}, {} broken link(s)",
                            r.dir,
                            r.missing_objects.len(),
                            r.referenced,
                            r.broken_links.len()
                        );
                        for corrupt in r.corrupt_objects.iter().take(NAMED_CORRUPT_OBJECTS) {
                            println!("         {corrupt}");
                        }
                        let rest = r.corrupt_objects.len().saturating_sub(NAMED_CORRUPT_OBJECTS);
                        if rest > 0 {
                            println!("         and {rest} more corrupt object(s)");
                        }
                    }
                }
                corrupt_hashes.extend(r.corrupt_objects.iter().map(|c| c.hash.clone()));
            }
            let ok = reports.len() - broken;
            println!("\n{ok}/{} builds consistent.", reports.len());
            if !corrupt_hashes.is_empty() {
                println!(
                    "{} distinct corrupt object(s) across the store; re-publishing the affected builds is the \
                     only fix.",
                    corrupt_hashes.len()
                );
            }
            if broken > 0 {
                bail!("{broken} build(s) inconsistent");
            }
            return Ok(());
        }
        Commands::Update { from, output, latest, build, version, force } => {
            let selector = if *latest {
                dump::SyncSelector::Latest
            } else if let Some(b) = build {
                dump::SyncSelector::Build(*b)
            } else if let Some(v) = version {
                dump::SyncSelector::Version(v.clone())
            } else {
                dump::SyncSelector::All
            };

            println!("Syncing from {} into {}...", from.display(), output.display());
            let synced = dump::sync_from_local(from, output, &selector, *force)?;
            for s in &synced {
                let status = if s.copied { "copied" } else { "already present" };
                println!("  {} (build {}) - {status}", s.version, s.build);
            }
            let copied = synced.iter().filter(|s| s.copied).count();
            println!("Done: {copied} copied, {} up to date.", synced.len() - copied);
            return Ok(());
        }
        // An explicit build + game directory dumps without manifest or registry.
        Commands::DumpRendererData { build: Some(b), game_dir: Some(gd), output, force, .. } => {
            let build = *b;
            let version_str = detect::detect_version_at_path(gd, build)
                .attach_with(|| format!("Could not detect version for build {build} at {}", gd.display()))?;
            let dir = dump::dump_dir(output, &version_str, build);
            if *force && dir.exists() {
                println!("Removing existing dump at {}...", dir.display());
                std::fs::remove_dir_all(&dir)?;
            }
            println!("Dumping build {build} ({version_str}) from {}", gd.display());
            let pb = dump::create_progress_bar(gd);
            dump::dump_renderer_data(gd, build, &version_str, output, pb.as_ref(), false)?;
            println!("Dumped to {}", dir.display());
            return Ok(());
        }
        _ => {}
    }

    let manifest = manifest::load_manifest(&repo_root.join("game_versions.toml"))?;
    let mut reg = registry::load_registry(&data_dir.join("versions.toml"));

    match args.command {
        Commands::Download { latest, build, version, force, username } => {
            let target = if latest {
                manifest.latest_build().ok_or_else(|| rootcause::report!("No versions in game_versions.toml"))?
            } else if let Some(b) = build {
                b
            } else if let Some(ref v) = version {
                manifest
                    .find_by_version(v)
                    .ok_or_else(|| rootcause::report!("No build found matching version '{v}'"))?
            } else {
                bail!("Specify --latest, --build, or --version");
            };

            if !force && reg.has_build(target) {
                println!("Build {target} already available. Use --force to re-download.");
                return Ok(());
            }

            let entry = manifest.get(target);
            download::download_build(target, entry, &data_dir, &repo_root, username.as_deref())?;

            let version_str = detect::detect_version_for_build(&data_dir, target)?;
            reg.set_downloaded(target, &version_str);
            registry::save_registry(&reg, &data_dir.join("versions.toml"))?;

            if entry.is_none() {
                println!();
                println!("This build is not in game_versions.toml. Add it with:");
                println!();
                println!("[versions.{target}]");
                println!("version = \"{version_str}\"");
                println!("depot_id = 552991");
                println!("manifest_id = \"<look up on SteamDB>\"");
            }
        }

        Commands::List => {
            if let Some(ref latest) = reg.latest_path {
                println!("Latest path: {}", latest.display());
                if let Ok(builds) = wowsunpack::game_data::list_available_builds(latest) {
                    println!("  builds: {:?}", builds);
                }
                println!();
            }

            println!("{:<12} {:<10} {:<24} STATUS", "BUILD", "VERSION", "MANIFEST");
            println!("{}", "-".repeat(72));

            let mut builds: Vec<_> = manifest.versions.keys().collect();
            builds.sort();

            for build_str in builds {
                let entry = &manifest.versions[build_str];
                let build: u32 = build_str.parse().unwrap_or(0);
                let status = if let Some(local) = reg.get(build) {
                    if let Some(ref path) = local.path {
                        format!("{} (registered)", path.display())
                    } else if let Some(ref ts) = local.downloaded_at {
                        format!("downloaded ({ts})")
                    } else {
                        "downloaded".to_string()
                    }
                } else {
                    "not available".to_string()
                };

                println!("{:<12} {:<10} {:<24} {}", build_str, entry.version, entry.manifest_id, status);
            }

            // Also show registry entries not in the manifest
            for (build_str, local) in &reg.builds {
                if !manifest.versions.contains_key(build_str) {
                    let status = if let Some(ref path) = local.path {
                        format!("{} (registered)", path.display())
                    } else {
                        "downloaded (not in manifest)".to_string()
                    };
                    println!("{:<12} {:<10} {:<24} {}", build_str, local.version, "-", status);
                }
            }
        }

        Commands::Detect { path } => {
            let scan_path = path.unwrap_or_else(|| data_dir.join("builds"));
            let detected = detect::detect_all_versions(&scan_path)?;
            if detected.is_empty() {
                println!("No game builds found in {}", scan_path.display());
            } else {
                for (build, version) in &detected {
                    println!("Build {build}: version {version}");
                    reg.set_downloaded(*build, version);
                }
                registry::save_registry(&reg, &data_dir.join("versions.toml"))?;
                println!("\nRegistry updated.");
            }
        }

        Commands::DumpRendererData { latest, build, version, output, force, game_dir: _ } => {
            let target = if latest {
                let builds = reg.available_builds();
                *builds.last().ok_or_else(|| rootcause::report!("No builds available"))?
            } else if let Some(b) = build {
                b
            } else if let Some(ref v) = version {
                manifest
                    .find_by_version(v)
                    .ok_or_else(|| rootcause::report!("No build found matching version '{v}'"))?
            } else {
                bail!("Specify --latest, --build, or --version");
            };

            let game_dir = reg
                .game_dir_for_build(target, &data_dir)
                .ok_or_else(|| rootcause::report!("Build {target} not available locally"))?;

            let version_str = if let Some(entry) = manifest.get(target) {
                entry.version.clone()
            } else {
                detect::detect_version_at_path(&game_dir, target).unwrap_or_else(|_| "unknown".to_string())
            };

            if force {
                // Remove stale builds.toml entry for this build
                let builds_path = output.join("builds.toml");
                let mut index = wows_data_mgr::builds::BuildsIndex::load(&builds_path);
                if index.find_by_build(target).is_some() {
                    // Find and remove the old directory
                    if let Some(old_entry) = index.find_by_build(target).cloned() {
                        let old_dir = output.join(&old_entry.dir);
                        if old_dir.exists() {
                            println!("Removing old dump at {}...", old_dir.display());
                            std::fs::remove_dir_all(&old_dir)?;
                        }
                    }
                    index.remove_build(target);
                    index.save(&builds_path)?;
                }

                // Also remove the new version dir if it exists
                let existing_dir = dump::dump_dir(&output, &version_str, target);
                if existing_dir.exists() {
                    println!("Removing existing dump at {}...", existing_dir.display());
                    std::fs::remove_dir_all(&existing_dir)?;
                }
            }

            println!("Building VFS from game directory...");
            let pb = dump::create_progress_bar(&game_dir);
            dump::dump_renderer_data(&game_dir, target, &version_str, &output, pb.as_ref(), false)?;
            println!("Dumped renderer data to {}", dump::dump_dir(&output, &version_str, target).display());
        }

        Commands::Remove { build, version, output } => {
            let index = wows_data_mgr::builds::BuildsIndex::load(&output.join("builds.toml"));

            if let Some(target_build) = build {
                println!("Removing build {target_build}...");
                dump::remove_build(&output, target_build)?;
                println!("Build {target_build} removed.");
            } else if let Some(ref version_query) = version {
                let matches = index.find_by_version(version_query);
                if matches.is_empty() {
                    bail!("No builds found matching version '{version_query}'");
                }
                let builds_to_remove: Vec<u32> = matches.iter().map(|e| e.build).collect();
                for b in &builds_to_remove {
                    println!("Removing build {b}...");
                    dump::remove_build(&output, *b)?;
                    println!("Build {b} removed.");
                }
            } else {
                bail!("Specify either --build or --version");
            }
        }

        Commands::RefreshDerived { .. }
        | Commands::Gc { .. }
        | Commands::RequiredPaths
        | Commands::Update { .. }
        | Commands::Verify { .. }
        | Commands::MigrateCas { .. }
        | Commands::CompleteBuild { .. } => {
            unreachable!("handled before manifest load")
        }

        Commands::Register { latest, version, build, path } => {
            if !path.exists() {
                bail!("Path does not exist: {}", path.display());
            }

            if latest {
                // Validate it looks like a WoWs install
                let builds = wowsunpack::game_data::list_available_builds(&path)
                    .attach_with(|| format!("No valid game builds found at {}", path.display()))?;

                if builds.is_empty() {
                    bail!("No builds found in {}/bin/", path.display());
                }

                reg.latest_path = Some(path.clone());
                registry::save_registry(&reg, &data_dir.join("versions.toml"))?;

                println!("Registered {} as latest path", path.display());
                println!("Currently available builds: {:?}", builds);
                return Ok(());
            }

            let builds = wowsunpack::game_data::list_available_builds(&path)
                .attach_with(|| format!("No valid game builds found at {}", path.display()))?;

            if builds.is_empty() {
                bail!("No builds found in {}/bin/", path.display());
            }

            let target_builds = if let Some(b) = build {
                if !builds.contains(&b) {
                    bail!("Build {b} not found at {}. Available: {:?}", path.display(), builds);
                }
                vec![b]
            } else if let Some(ref v) = version {
                let mut matched = Vec::new();
                for &b in &builds {
                    if let Ok(detected) = detect::detect_version_at_path(&path, b)
                        && manifest::version_matches(&detected, v)
                    {
                        matched.push(b);
                    }
                }
                if matched.is_empty() {
                    bail!("No builds matching version '{v}' found at {}", path.display());
                }
                matched
            } else {
                builds
            };

            for b in target_builds {
                let version_str = detect::detect_version_at_path(&path, b).unwrap_or_else(|_| "unknown".to_string());
                reg.set_registered(b, &version_str, &path);
                println!("Registered build {b} (version {version_str}) at {}", path.display());
            }

            registry::save_registry(&reg, &data_dir.join("versions.toml"))?;
        }
    }

    Ok(())
}