dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 9ffbdb14b746f421734fd66435a330b033edbad6
parent e0161df4361701471430efb134e1f37906bd6226
Author: sin <sin@2f30.org>
Date:   Mon, 18 Feb 2019 13:33:13 +0000

Don't flush cache if it hasn't been modified

Diffstat:
Mdedup.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -78,6 +78,7 @@ int ifd; int sfd; int cfd; int verbose; +int cache_dirty; char *argv0; /* @@ -285,6 +286,9 @@ flush_cache(void) { struct cent *cent; + if (!cache_dirty) + return; + lseek(cfd, 0, SEEK_SET); RB_FOREACH(cent, cache, &cache_head) xwrite(cfd, &cent->bdescr, sizeof(cent->bdescr)); @@ -451,6 +455,7 @@ dedup(int fd, char *msg) cent = alloc_cent(); cent->bdescr = bdescr; add_cent(cent); + cache_dirty = 1; enthdr.st.actual_bytes += bdescr.size; enthdr.st.cache_misses++; @@ -583,6 +588,7 @@ rebuild_cache(struct ent *ent, void *arg) memcpy(cent->bdescr.md, md, sizeof(cent->bdescr.md)); cent->bdescr = ent->bdescr[i]; add_cent(cent); + cache_dirty = 1; } free(buf); return WALK_CONTINUE;