Skip to content

refactor: extract hm-util crate + modernize CancellationToken#5

Merged
markovejnovic merged 26 commits into
mainfrom
refactor/code-reorg
May 23, 2026
Merged

refactor: extract hm-util crate + modernize CancellationToken#5
markovejnovic merged 26 commits into
mainfrom
refactor/code-reorg

Conversation

@markovejnovic
Copy link
Copy Markdown
Contributor

@markovejnovic markovejnovic commented May 23, 2026

No description provided.

…cellationToken

Eliminates 55-line Arc<AtomicBool> wrapper. The 50ms polling loop in
wait_cancel is replaced by the zero-cost .cancelled() future.
Add hm-util to workspace crate listing. Update orchestrator docs to
reflect CancellationToken is now tokio_util::sync, not a custom module.
Main removed anyhow from workspace.dependencies; hm-util still
referenced it via workspace = true.
- os::fs returns std::io::Result instead of anyhow::Result
- os::dirs returns Option<PathBuf> instead of anyhow::Result
- os::dirs adds sys_config_dir() for /etc (Unix) / C:\ProgramData (Win)
- New top-level dirs module for harmont config dir discovery
  (searches ~/.hm then /etc/hm)
- Update hm callers for new return types
- Merge os::dirs primitives (home_dir, config_dir, sys_config_dir) into
  hm_util::dirs alongside harmont-specific discovery
- Delete os/dirs.rs — hm_util::dirs is the sole public API
- Update all hm callers from hm_util::os::dirs to hm_util::dirs
- Add prohibition comment in hm/src/lib.rs: dirs crate must not be
  added as a direct dependency of hm
Move raw `dirs::` calls into private `os::dirs` module within hm-util.
Public `hm_util::dirs` now exposes only Harmont-specific accessors:
harmont_config_dir, harmont_data_dir, harmont_plugins_dir,
harmont_plugin_state_dir. No raw system directory calls leak into hm.
unreachable_pub (rustc) and redundant_pub_crate (clippy) contradict
each other for pub(crate) items inside non-pub modules. Keep the
rustc lint, suppress the clippy one globally.
Remove duplicate sync code paths — blocking:: now shells out to the
async API through tokio::task::block_in_place. Platform-specific
rename logic moves from standalone _sync functions to private _impl
helpers positioned after the public async fn.
atomic_rename_over now delegates to tokio::fs::rename on Unix.
write_atomic_restricted splits its spawn_blocking so the rename
step goes through the async atomic_rename_over. The sync Unix
atomic_rename_over_impl is removed (only Windows variant remains).
create_dir_with_mode and write_file_with_mode now use tokio::fs
instead of std::fs. This eliminates the last spawn_blocking from
write_atomic_restricted — all I/O goes through tokio's async API.
@markovejnovic markovejnovic marked this pull request as ready for review May 23, 2026 22:00
@markovejnovic markovejnovic merged commit c8896b5 into main May 23, 2026
22 checks passed
@markovejnovic markovejnovic deleted the refactor/code-reorg branch May 23, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant