Don't flush cache if it hasn't been modified - dedup - deduplicating backup program
 (HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9ffbdb14b746f421734fd66435a330b033edbad6
 (DIR) parent e0161df4361701471430efb134e1f37906bd6226
 (HTM) 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:
         M dedup.c                             |       6 ++++++
       
       1 file changed, 6 insertions(+), 0 deletions(-)
       ---
 (DIR) 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;