| ... | @@ -256,10 +256,10 @@ static Error populate_file_hash(CacheHash *ch, CacheHashFile *chf, Buf *contents | ... | @@ -256,10 +256,10 @@ static Error populate_file_hash(CacheHash *ch, CacheHashFile *chf, Buf *contents |
| 256 | } | 256 | } |
| 257 | | 257 | |
| 258 | if ((err = hash_file(chf->bin_digest, this_file, contents))) { | 258 | if ((err = hash_file(chf->bin_digest, this_file, contents))) { |
| 259 | os_file_close(this_file); | 259 | os_file_close(&this_file); |
| 260 | return err; | 260 | return err; |
| 261 | } | 261 | } |
| 262 | os_file_close(this_file); | 262 | os_file_close(&this_file); |
| 263 | | 263 | |
| 264 | blake2b_update(&ch->blake, chf->bin_digest, 48); | 264 | blake2b_update(&ch->blake, chf->bin_digest, 48); |
| 265 | | 265 | |
| ... | @@ -300,7 +300,7 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -300,7 +300,7 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 300 | Buf line_buf = BUF_INIT; | 300 | Buf line_buf = BUF_INIT; |
| 301 | buf_resize(&line_buf, 512); | 301 | buf_resize(&line_buf, 512); |
| 302 | if ((err = os_file_read_all(ch->manifest_file, &line_buf))) { | 302 | if ((err = os_file_read_all(ch->manifest_file, &line_buf))) { |
| 303 | os_file_close(ch->manifest_file); | 303 | os_file_close(&ch->manifest_file); |
| 304 | return err; | 304 | return err; |
| 305 | } | 305 | } |
| 306 | | 306 | |
| ... | @@ -389,14 +389,14 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -389,14 +389,14 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 389 | OsFileAttr actual_attr; | 389 | OsFileAttr actual_attr; |
| 390 | if ((err = os_file_open_r(chf->path, &this_file, &actual_attr))) { | 390 | if ((err = os_file_open_r(chf->path, &this_file, &actual_attr))) { |
| 391 | fprintf(stderr, "Unable to open %s\n: %s", buf_ptr(chf->path), err_str(err)); | 391 | fprintf(stderr, "Unable to open %s\n: %s", buf_ptr(chf->path), err_str(err)); |
| 392 | os_file_close(ch->manifest_file); | 392 | os_file_close(&ch->manifest_file); |
| 393 | return ErrorCacheUnavailable; | 393 | return ErrorCacheUnavailable; |
| 394 | } | 394 | } |
| 395 | if (chf->attr.mtime.sec == actual_attr.mtime.sec && | 395 | if (chf->attr.mtime.sec == actual_attr.mtime.sec && |
| 396 | chf->attr.mtime.nsec == actual_attr.mtime.nsec && | 396 | chf->attr.mtime.nsec == actual_attr.mtime.nsec && |
| 397 | chf->attr.inode == actual_attr.inode) | 397 | chf->attr.inode == actual_attr.inode) |
| 398 | { | 398 | { |
| 399 | os_file_close(this_file); | 399 | os_file_close(&this_file); |
| 400 | } else { | 400 | } else { |
| 401 | // we have to recompute the digest. | 401 | // we have to recompute the digest. |
| 402 | // later we'll rewrite the manifest with the new mtime/digest values | 402 | // later we'll rewrite the manifest with the new mtime/digest values |
| ... | @@ -411,11 +411,11 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -411,11 +411,11 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 411 | | 411 | |
| 412 | uint8_t actual_digest[48]; | 412 | uint8_t actual_digest[48]; |
| 413 | if ((err = hash_file(actual_digest, this_file, nullptr))) { | 413 | if ((err = hash_file(actual_digest, this_file, nullptr))) { |
| 414 | os_file_close(this_file); | 414 | os_file_close(&this_file); |
| 415 | os_file_close(ch->manifest_file); | 415 | os_file_close(&ch->manifest_file); |
| 416 | return err; | 416 | return err; |
| 417 | } | 417 | } |
| 418 | os_file_close(this_file); | 418 | os_file_close(&this_file); |
| 419 | if (memcmp(chf->bin_digest, actual_digest, 48) != 0) { | 419 | if (memcmp(chf->bin_digest, actual_digest, 48) != 0) { |
| 420 | memcpy(chf->bin_digest, actual_digest, 48); | 420 | memcpy(chf->bin_digest, actual_digest, 48); |
| 421 | // keep going until we have the input file digests | 421 | // keep going until we have the input file digests |
| ... | @@ -433,12 +433,12 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -433,12 +433,12 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 433 | CacheHashFile *chf = &ch->files.at(file_i); | 433 | CacheHashFile *chf = &ch->files.at(file_i); |
| 434 | if ((err = populate_file_hash(ch, chf, nullptr))) { | 434 | if ((err = populate_file_hash(ch, chf, nullptr))) { |
| 435 | fprintf(stderr, "Unable to hash %s: %s\n", buf_ptr(chf->path), err_str(err)); | 435 | fprintf(stderr, "Unable to hash %s: %s\n", buf_ptr(chf->path), err_str(err)); |
| 436 | os_file_close(ch->manifest_file); | 436 | os_file_close(&ch->manifest_file); |
| 437 | return ErrorCacheUnavailable; | 437 | return ErrorCacheUnavailable; |
| 438 | } | 438 | } |
| 439 | } | 439 | } |
| 440 | if (return_code != ErrorNone) { | 440 | if (return_code != ErrorNone) { |
| 441 | os_file_close(ch->manifest_file); | 441 | os_file_close(&ch->manifest_file); |
| 442 | } | 442 | } |
| 443 | return return_code; | 443 | return return_code; |
| 444 | } | 444 | } |
| ... | @@ -453,7 +453,7 @@ Error cache_add_file_fetch(CacheHash *ch, Buf *resolved_path, Buf *contents) { | ... | @@ -453,7 +453,7 @@ Error cache_add_file_fetch(CacheHash *ch, Buf *resolved_path, Buf *contents) { |
| 453 | CacheHashFile *chf = ch->files.add_one(); | 453 | CacheHashFile *chf = ch->files.add_one(); |
| 454 | chf->path = resolved_path; | 454 | chf->path = resolved_path; |
| 455 | if ((err = populate_file_hash(ch, chf, contents))) { | 455 | if ((err = populate_file_hash(ch, chf, contents))) { |
| 456 | os_file_close(ch->manifest_file); | 456 | os_file_close(&ch->manifest_file); |
| 457 | return err; | 457 | return err; |
| 458 | } | 458 | } |
| 459 | | 459 | |
| ... | @@ -586,6 +586,6 @@ void cache_release(CacheHash *ch) { | ... | @@ -586,6 +586,6 @@ void cache_release(CacheHash *ch) { |
| 586 | } | 586 | } |
| 587 | } | 587 | } |
| 588 | | 588 | |
| 589 | os_file_close(ch->manifest_file); | 589 | os_file_close(&ch->manifest_file); |
| 590 | } | 590 | } |
| 591 | | 591 | |