Skip to content

Commit

Permalink
Merge pull request #68 from MecryWork/master
Browse files Browse the repository at this point in the history
fix: Failed to mount an empty file in the cache state
  • Loading branch information
fangfufu authored Jul 27, 2021
2 parents fa586cd + 2791f96 commit df94764
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ static int Meta_write(Cache *cf)
fwrite(&cf->content_length, sizeof(off_t), 1, fp);
fwrite(&cf->blksz, sizeof(int), 1, fp);
fwrite(&cf->segbc, sizeof(long), 1, fp);
fwrite(cf->seg, sizeof(Seg), cf->segbc, fp);
if (cf->content_length){
fwrite(cf->seg, sizeof(Seg), cf->segbc, fp);
}

/* Error checking for fwrite */
if (ferror(fp)) {
Expand Down Expand Up @@ -807,7 +809,7 @@ Cache *Cache_open(const char *fn)
/*
* Internally inconsistent or corrupt metadata
*/
if ((rtn == EINCONSIST) || (rtn == EZERO) || (rtn == EMEM)) {
if ((rtn == EINCONSIST) || (rtn == EMEM)) {
Cache_free(cf);
fprintf(stderr, "Cache_open(): metadata error: %s, %d.\n", fn, rtn);
return NULL;
Expand Down

0 comments on commit df94764

Please sign in to comment.