Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion duperemove.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ enum {
QUIET_OPTION,
EXCLUDE_OPTION,
BATCH_SIZE_OPTION,
MIN_FILESIZE_OPTION,
};

static int process_fdupes(void)
Expand Down Expand Up @@ -316,14 +317,15 @@ static int parse_options(int argc, char **argv, int *filelist_idx)
{ "quiet", 0, NULL, QUIET_OPTION },
{ "exclude", 1, NULL, EXCLUDE_OPTION },
{ "batchsize", 1, NULL, BATCH_SIZE_OPTION },
{ "min-filesize", 1, NULL, MIN_FILESIZE_OPTION },
{ NULL, 0, NULL, 0}
};

if (argc < 2) {
help(); /* Never returns */
}

while ((c = getopt_long(argc, argv, "b:vdDrh?LRqB:", long_ops, NULL))
while ((c = getopt_long(argc, argv, "b:vdDrh?LRqBm:", long_ops, NULL))
!= -1) {
switch (c) {
case 'b':
Expand Down Expand Up @@ -411,6 +413,15 @@ static int parse_options(int argc, char **argv, int *filelist_idx)
case 'B':
options.batch_size = parse_size(optarg);
break;
case MIN_FILESIZE_OPTION:
case 'm':
options.min_filesize = parse_size(optarg);
if (options.min_filesize == 0){
eprintf("Error: --min-filesize must be "
"larger zero\n");
return EINVAL;
}
break;
case HELP_OPTION:
help();
break;
Expand Down
4 changes: 2 additions & 2 deletions file_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ bool check_file(struct dbhandle *db, char *path, struct statx *st, bool parent_c
return false;
}

if (S_ISREG(st->stx_mode) && st->stx_size == 0) {
vprintf("Skipping empty file %s\n", path);
if (S_ISREG(st->stx_mode) && st->stx_size < options.min_filesize) {
vprintf("Skipping too small file %s (is %llu, minimum %lu)\n", path, st->stx_size, options.min_filesize);
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions markdown/duperemove.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ shells usually expand glob pattern so the passed in pattern ought to also be
quoted. Taking everything into consideration the correct way to pass an exclusion
pattern is `duperemove --exclude "/path/to/dir/file*" /path/to/dir`

**-m** `N`, **\--min-filesize**=`N`
~ All files smaller than the given size are excluded from the deduplication process.
This may speed up things significantly.

# EXAMPLES

## Simple Usage
Expand Down
1 change: 1 addition & 0 deletions opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ struct options options = {
.dedupe_same_file = true,
.batch_size = 1024,
.fdupes_mode = false,
.min_filesize = 1,
};
2 changes: 2 additions & 0 deletions opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define __OPT_H__

#include <stdbool.h>
#include <stdint.h>

struct options {
int run_dedupe;
Expand All @@ -27,6 +28,7 @@ struct options {
bool dedupe_same_file : 1;
unsigned int batch_size;
bool fdupes_mode : 1;
uint64_t min_filesize;
char *hashfile;
};

Expand Down