Skip to content

Commit

Permalink
duperemove: register the hashfile in the exclusion list
Browse files Browse the repository at this point in the history
If the hashfile is stored in the dataset, then every run will
need to rescan the hashfile itself, with no chance of deduplication.

Fixes #335

Signed-off-by: Alexandre Bruyelles <git@jack.fr.eu.org>
  • Loading branch information
JackSlateur committed Oct 6, 2024
1 parent 71b3596 commit b76d569
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions duperemove.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,20 @@ static int parse_options(int argc, char **argv, int *filelist_idx)
else if (update_hashes)
use_hashfile = H_UPDATE;

/*
* Always add the hashfile and its wal etc to the exclude list
* A wildcard would be easier but may exclude extra files silently,
* this would be confusing for the user.
*/
if (options.hashfile != NULL) {
char tmp[PATH_MAX + 10 ] = {0,};
add_exclude_pattern(options.hashfile);
snprintf(tmp, PATH_MAX + 9, "%s-wal", options.hashfile);
add_exclude_pattern(tmp);
snprintf(tmp, PATH_MAX + 9, "%s-shm", options.hashfile);
add_exclude_pattern(tmp);
}

if (read_hashes) {
if (numfiles) {
eprintf("Error: --read-hashes option does not take a "
Expand Down

0 comments on commit b76d569

Please sign in to comment.