diff options
| author | Thorsten Töpper <atsutane@freethoughts.de> | 2026-03-01 21:10:48 +0100 |
|---|---|---|
| committer | Thorsten Töpper <atsutane@freethoughts.de> | 2026-03-01 21:10:48 +0100 |
| commit | b551c441e10c94ccfe188d9bcc783efe78cd5083 (patch) | |
| tree | b5e88509bd6155fb7af9a3e54efcf66adef541a0 /src/file_processor.c | |
| parent | 951ba68794bc228e00c40d36cca44c65da69603c (diff) | |
| download | duplicate_finder-b551c441e10c94ccfe188d9bcc783efe78cd5083.tar.gz duplicate_finder-b551c441e10c94ccfe188d9bcc783efe78cd5083.tar.bz2 | |
file_processor: Skip files already in the DB with same size and mtime
Diffstat (limited to 'src/file_processor.c')
| -rw-r--r-- | src/file_processor.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/file_processor.c b/src/file_processor.c index b2b4f85..0f4af9f 100644 --- a/src/file_processor.c +++ b/src/file_processor.c @@ -190,6 +190,7 @@ int process_file(struct df_fileinfo *info) { size_t bytes_read; struct df_md_components *ctx_pkg; bool error_in_loop = false; + struct df_fileinfo info_from_db; unsigned char md_val[EVP_MAX_MD_SIZE]; unsigned int md_len; @@ -218,6 +219,24 @@ int process_file(struct df_fileinfo *info) { return -1; } + /* filesystem information collected check whether the DB has a corresponding value, + * if so check by size and time whether it looks modified if not, skip + * TODO: option_force needs to be implemented AND memory clean up*/ + info_from_db.path = info->path; + info_from_db.name = info->name; + if ((dbi_fill_fileinfo(&info_from_db) == 0) && + (info->statbuf.st_size == info_from_db.statbuf.st_size) && + (info->statbuf.st_mtim.tv_sec < info_from_db.last_seen) && + (info->statbuf.st_mtim.tv_sec == info_from_db.statbuf.st_mtim.tv_sec) && + (info->statbuf.st_mtim.tv_nsec == info_from_db.statbuf.st_mtim.tv_nsec)) { + if ( ! option_quiet ) { + LOGERR("Skip file '%s' file unchanged according to metadata\n", fullpath); + } + dbi_update_fileinfo_last_seen(info_from_db.id); + return 0; + } + + if ((ctx_pkg = init_md_components()) == NULL) { LOGERR("ERROR: Failed to initialize/create md contexts to be used with %s\n", fullpath); |
