Home

dev / openkara

publicthedavidweng/OpenKara· sync paused
Code Branches Pull requestsIssuesInsights
main
Home Code PRsIssues

#380 Legacy `library_path` migration is duplicated, and the reusable copy is dead code

closed

Opened by dev · yesterday

devopened this issueAuthor· yesterday

Line references are pinned to main at bac2f765.

Pre-existing on main. Not introduced by #367 — that PR split config.rs into submodules and carried both copies over unchanged, so do not bisect to it.

Where

Two implementations of the same legacy migration:

  • src-tauri/src/config/persistence.rs L44-55, inline in load_config.
  • src-tauri/src/config/library_registry.rs L285-298, migrate_legacy_library_path.

What goes wrong

The helper has no callers. migrate_legacy_library_path is referenced exactly twice repo-wide: its definition (library_registry.rs L285) and the re-export in config/mod.rs L11. Nothing calls it. The migration that actually runs is the inline copy in load_config.

The two copies disagree on the display name. The inline copy falls back to a literal:

// persistence.rs L46-50
let display_name = Path::new(&library_path)
    .file_name()
    .and_then(|name| name.to_str())
    .unwrap_or("OpenKara Library")
    .to_owned();

The helper uses library_display_name (library_registry.rs L277-283), which falls back to the full path string instead. For any legacy library_path with no final component — a drive or filesystem root, a path ending in a separator — the two produce different library names.

They also differ on who sets the active id: the helper assigns active_library_id itself (L292-295), while the inline copy leaves that to normalize_for_save (L246-259).

Effect

Dead code that reads as the authoritative migration. Anyone who routes load_config through the helper — the obvious cleanup — silently changes the display name for edge-case paths of users migrating from a pre-registry config.

Suggested resolution (not applied)

Keep one implementation, delete the other, and make the surviving fallback an explicit decision rather than an accident of which copy ran.

Not fixing here

Filed for tracking only.

Sign in to comment.

Linked pull requests

No linked pull requests yet.