Commit Graph

42 Commits

Author SHA1 Message Date
Sreedev Kodichath
2a5324b48c [ADD] tui: interactive terminal UI for resolving duplicates
The tool could only act on duplicates non-interactively or through a
line-oriented per-group prompt. Add a full-screen terminal UI (--tui) for
browsing and resolving them visually.

The UI is a two-pane master/detail view: a list of duplicate groups and,
for the selected group, its files with per-file deletion marks. Files can
be marked individually or in bulk by a keep-strategy (newest/oldest/first/
last/shortest/shallowest, reused from the resolver) applied to the current
group or to all groups at once. A footer tracks how many files are marked
and how much space would be reclaimed. Deletion is gated behind an explicit
confirmation, a group always keeps at least one file, and the highlighted
file can be opened in the system default application.

The design keeps the interaction logic pure and independently testable: an
App model translates an abstract key event into an outcome, so navigation,
marking, strategy application, and post-deletion model updates are all unit
tested without a terminal. Rendering (ratatui) and the destructive file I/O
live in the event loop, which restores the terminal on both normal exit and
panic so a crash never leaves it broken. --tui is mutually exclusive with
--keep and --interactive.
2026-07-26 22:02:17 +02:00
Sreedev Kodichath
1442cd0aaf [ADD] cache: on-disk hash cache for faster re-runs
Content hashing is the pipeline's expensive stage; every run re-read and
re-hashed all size-collision candidates from scratch. Persist those hashes
so an unchanged file is skipped on subsequent runs.

Add a path-keyed cache mapping absolute_path -> (size, mtime, strict, hash,
last_seen), stored in a compact hand-rolled little-endian binary format with
a magic+version header. A candidate reuses its stored hash only when size,
mtime, and hash-mode all match; otherwise it is re-hashed and the entry is
refreshed. On save, entries unseen for 30 days are pruned so the file cannot
grow without bound. The hashing stage splits into hash_candidates (parallel,
cache-consulting) and group_hashed (grouping) so lookups stay inside the
parallel pass while cache mutation stays single-threaded after it.

The cache is strictly a performance hint: a missing, corrupt, version-
mismatched, or unwritable cache degrades to a correct full-hash run and
never fails or changes the result. Caching is on by default at the platform
cache directory; --no-cache disables it and --cache-file overrides the path.

The gxhash seed becomes a fixed constant so stored hashes are reproducible
across runs, which is what makes cache hits possible; rand is consequently
no longer a production dependency (now dev-only), and dirs is added for the
platform cache directory.
2026-07-26 20:53:41 +02:00
Sreedev Kodichath
3ca931fa8e [REF] core: replace streaming pipeline with staged batch pipeline
The deduplication core was a three-stage streaming producer/consumer
(scan -> group-by-size -> group-by-hash) orchestrated by a Server struct
that ran the stages concurrently on a threadpool. Coordination relied on
AtomicBool flags polled in busy-wait loops, an Arc<Mutex<Vec>> hand-off
queue, DashMap stores, and a per-file Arc<Mutex<FileState>>. Every stage
had to receive its own hand-cloned Arcs with ad-hoc names, and the
busy-wait branches burned a core spinning while waiting for the producer.

Replace it with a staged batch pipeline over owned collections:
pipeline::run(&Params) drives scan -> group_by_size -> group_by_hash in
sequence, with rayon supplying parallelism. With no shared mutable state
between stages, all the Arc plumbing, the AtomicBool coordination, the
Mutex queue, the per-file lock, server.rs, and the threadpool/dashmap
dependencies are gone. FileInfo becomes plain data and each stage is a
pure, independently testable function.

Behavior is preserved except for three authorized deviations: progress
spinners render sequentially rather than concurrently under -p; the
interactive empty-result message prints once instead of twice; and the
interactive "Duplicate Set X of Y" total now counts the confirmed
duplicate groups shown instead of the internal candidate-hash store size.

This lands as the foundation for the cache, CLI, and TUI work that follows.
2026-07-26 14:27:02 +02:00
sreedevk
da24efbb36 count graphemes instead of chars in path length check 2025-07-30 10:47:58 +00:00
sreedevk
f5d2d4e22c fix: single file hash groups printed to screen 2025-07-19 14:22:43 +00:00
sreedevk
e78dfc4211 updated dependencies 2025-07-19 02:01:15 +00:00
sreedevk
130a8f99ba partial hash page count increased 2025-07-18 11:25:37 +00:00
Sreedev Kodichath
58e33cc8da v0.3 (#61)
- [x] parallelization
    - [x] (scanning) + (processing sw & processing hw & formatting & printing)
- [x] reduce cloning values on the heap
- [x] add a partial hashing mode (--strict)
- [x] add unit tests
- [x] add silent mode
- [x] update documentation
- [x] remove color output
- [x] progress bar improvements
    - [x] use progress bar groups
- [x] remove broken json rendering
- [x] add benchmarks
2025-07-13 19:03:14 -04:00
sreedevk
f9e86f8522 performance improvements 2025-07-12 00:24:25 +00:00
Sreedev Kodichath
028b868ea9 version 0.2.2 (#59)
* replaced fxhash with gxhash
2024-07-04 23:23:01 -04:00
sreedev
b16236763c updated readme + version number 2023-11-14 18:36:27 -05:00
sreedev
3e407f69c8 added json output for further processing using other tools 2023-11-14 18:33:40 -05:00
sreedev
e3d48ec505 v0.2.0 2023-07-17 13:59:58 -04:00
sreedev
493cac1762 upgraded dependencies 2023-01-26 14:17:54 -05:00
sreedev
f0dbf05705 removed tokio & other unused dependencies 2023-01-26 14:07:50 -05:00
sreedev
b49940998b version 0.1.6 2023-01-25 21:27:31 -05:00
sreedev
7d66aeef6e version 0.1.5 2023-01-23 19:02:09 -05:00
sreedev
b1c508e9e7 versioning changes 2023-01-23 18:33:06 -05:00
beeb
6f8b1d55df feat: switch to globwalk 2023-01-23 21:53:44 +01:00
sreedev
876fdc69ac added version changes 2023-01-23 02:20:42 -05:00
dependabot[bot]
ccff95dfc5 build(deps): bump tokio from 1.23.0 to 1.23.1
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.23.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.23.0...tokio-1.23.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-21 01:57:43 +00:00
sreedev
c0042fc9f7 version 0.1.2 release changes 2023-01-19 09:40:58 -05:00
sreedev
0e624b042d added minsize filter 2023-01-18 02:30:48 -05:00
sreedev
8ac78fb856 version 0.1.1 2023-01-18 00:32:53 -05:00
sreedev
ea748c60d8 performance tweaks 2023-01-18 00:24:50 -05:00
sreedev
51f5f8e61a incremental hashing + remove sqlite + mmap file reads 2023-01-17 23:40:57 -05:00
sreedev
64d0106765 version changes 2023-01-13 00:53:46 -05:00
sreedev
12295d7847 version 0.0.8 2023-01-11 19:28:34 -05:00
sreedev
dbf504fc17 added progress bar 2023-01-11 15:55:31 -05:00
sreedev
533f81f724 version 0.0.7 2023-01-10 20:26:03 -05:00
sreedev
b5bb58b3ed version changes 2023-01-09 22:47:54 -05:00
sreedev
a0083cb571 table printing added 2023-01-09 22:15:44 -05:00
sreedev
96fe667d3f version 0.0.5 2023-01-09 11:08:20 -05:00
sreedev
e158a8267a added authors & updated version 2023-01-08 17:16:46 -05:00
sreedev
3a7ac7a332 version 0.0.3 2023-01-07 07:04:03 -05:00
sreedev
e852f42ac6 ui updates 2023-01-02 02:24:05 -05:00
sreedev
68286afab3 removed old hashing lib 2022-12-30 00:30:52 -05:00
sreedev
2cfb298468 faster hashing algorithm 2022-12-30 00:25:07 -05:00
sreedev
57083a7346 added nocache option 2022-12-29 23:48:34 -05:00
sreedev
4c9f848140 filetype requirement removed 2022-12-27 21:19:13 -05:00
sreedev
f8242ca4ac printing sizes added 2022-12-27 21:05:41 -05:00
sreedev
3b06c0851f initial commit 2022-12-24 18:45:16 -05:00