URI: 
       Fix bug - dedup - deduplicating backup program
  HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 4a9c691eb97725f224362ee65dc088f0260bc8b6
   DIR parent 6d6109301d421104c4d298b7d44914e45ad9e465
  HTML Author: sin <sin@2f30.org>
       Date:   Wed, 21 Mar 2018 13:21:41 +0000
       
       Fix bug
       
       Diffstat:
         M dedup.c                             |      14 +++++++++-----
       
       1 file changed, 9 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/dedup.c b/dedup.c
       @@ -148,8 +148,6 @@ hash_ent_add(unsigned char *md, uint64_t blkidx)
                memcpy(&hash_ent->cent.md, md, sizeof(hash_ent->cent.md));
                hash_ent->cent.blkidx = blkidx;
                RB_INSERT(hash_tree, &hash_tree_head, hash_ent);
       -        lseek(cfd, 0, SEEK_END);
       -        xwrite(cfd, &hash_ent->cent, sizeof(hash_ent->cent));
                return hash_ent;
        }
        
       @@ -266,10 +264,13 @@ dedup(int fd)
                        ent = grow_ent(ent, ent->nblks + 1);
        
                        if (lookup_blk(&blk, &blkidx) == -1) {
       +                        struct hash_ent *hash_ent;
                                uint64_t nblks = storefile_nblks();
        
                                ent->blks[ent->nblks++] = nblks;
       -                        hash_ent_add(blk.md, nblks);
       +                        hash_ent = hash_ent_add(blk.md, nblks);
       +                        lseek(cfd, 0, SEEK_END);
       +                        xwrite(cfd, &hash_ent->cent, sizeof(hash_ent->cent));
                                append_blk(&blk);
                        } else {
                                ent->blks[ent->nblks++] = blkidx;
       @@ -338,10 +339,12 @@ rebuild_cache(void)
                nblks = storefile_nblks();
                lseek(cfd, 0, SEEK_SET);
                for (i = 0; i < nblks; i++) {
       +                struct hash_ent *hash_ent;
                        struct blk blk;
        
                        read_blk(&blk, i);
       -                hash_ent_add(blk.md, i);
       +                hash_ent = hash_ent_add(blk.md, i);
       +                xwrite(cfd, &hash_ent->cent, sizeof(hash_ent->cent));
                }
        }
        
       @@ -451,8 +454,9 @@ list(void)
                for (i = 0; i < enthdr.nents; i++) {
                        struct ent ent;
        
       -                if (xread(ifd, &ent, sizeof(ent)) == 0)
       +                if (xread(ifd, &ent, sizeof(ent)) == 0) {
                                errx(1, "unexpected EOF");
       +                }
                        dump_md(ent.md, sizeof(ent.md));
                        putchar('\n');
                        lseek(ifd, ent.nblks * sizeof(ent.blks[0]), SEEK_CUR);