// When a backup is ongoing, use this to add newly complete candidates. int candidate_add_fresh(const char *path, struct conf *conf) { int ars; int ret=-1; gzFile zp=NULL; const char *cp=NULL; struct sbuf *sb=NULL; struct candidate *candidate=NULL; struct blk *blk=NULL; if(!(candidate=candidates_add_new())) goto end; cp=path+strlen(conf->directory); while(cp && *cp=='/') cp++; if(!(candidate->path=strdup(cp))) { log_out_of_memory(__func__); goto end; } if(!(sb=sbuf_alloc(conf)) || !(blk=blk_alloc()) || !(zp=gzopen_file(path, "rb"))) goto end; while(zp) { if((ars=sbuf_fill_from_gzfile(sb, NULL /* struct async */, zp, blk, NULL, conf))<0) goto end; else if(ars>0) { // Reached the end. break; } if(!*(blk->weak)) continue; if(is_hook(blk->weak)) { if(sparse_add_candidate(blk->weak, candidate)) goto end; } *blk->weak='\0'; } if(scores_grow(scores, candidates_len)) goto end; candidates_set_score_pointers(candidates, candidates_len, scores); scores_reset(scores); //printf("HERE: %d candidates\n", (int)candidates_len); ret=0; end: gzclose_fp(&zp); sbuf_free(sb); blk_free(blk); return ret; }
int manio_write_sig_and_path(struct manio *manio, struct blk *blk) { if(manio->hook_sort && is_hook(blk->weak)) { // Add to list of hooks for this manifest chunk. snprintf(manio->hook_sort[manio->hook_count++], WEAK_STR_LEN, "%s", blk->weak); } if(manio->dindex_sort) { // Ignore obvious duplicates. if(!manio->hook_count || strncmp(manio->dindex_sort[manio->hook_count-1], blk->save_path, SAVE_PATH_LEN)) { // Add to list of dindexes for this manifest chunk. snprintf(manio->dindex_sort[manio->dindex_count++], SAVE_PATH_STR_LEN, "%s", blk->save_path); } } return write_sig_msg(manio, sig_to_msg(blk, 1 /* save_path */)); }
int manio_write_sig_and_path(struct manio *manio, struct blk *blk) { if(manio->hook_sort && is_hook(blk->fingerprint)) { // Add to list of hooks for this manifest chunk. snprintf(manio->hook_sort[manio->hook_count++], WEAK_STR_LEN, "%016"PRIX64, blk->fingerprint); } if(manio->dindex_sort) { char *savepathstr=bytes_to_savepathstr(blk->savepath); // Ignore obvious duplicates. if(!manio->hook_count || strncmp(manio->dindex_sort[manio->hook_count-1], savepathstr, MSAVE_PATH_LEN)) { // Add to list of dindexes for this manifest chunk. snprintf(manio->dindex_sort[manio->dindex_count++], MSAVE_PATH_LEN+1, "%s", savepathstr); } } return write_sig_msg(manio, sig_to_msg(blk, 1 /* save_path */)); }