| ... | ... | @@ -256,10 +256,10 @@ static Error populate_file_hash(CacheHash *ch, CacheHashFile *chf, Buf *contents |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | if ((err = hash_file(chf->bin_digest, this_file, contents))) { |
| 259 | | os_file_close(this_file); |
| 259 | os_file_close(&this_file); |
| 260 | 260 | return err; |
| 261 | 261 | } |
| 262 | | os_file_close(this_file); |
| 262 | os_file_close(&this_file); |
| 263 | 263 | |
| 264 | 264 | blake2b_update(&ch->blake, chf->bin_digest, 48); |
| 265 | 265 | |
| ... | ... | @@ -300,7 +300,7 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 300 | 300 | Buf line_buf = BUF_INIT; |
| 301 | 301 | buf_resize(&line_buf, 512); |
| 302 | 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 | 304 | return err; |
| 305 | 305 | } |
| 306 | 306 | |
| ... | ... | @@ -389,14 +389,14 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 389 | 389 | OsFileAttr actual_attr; |
| 390 | 390 | if ((err = os_file_open_r(chf->path, &this_file, &actual_attr))) { |
| 391 | 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 | 393 | return ErrorCacheUnavailable; |
| 394 | 394 | } |
| 395 | 395 | if (chf->attr.mtime.sec == actual_attr.mtime.sec && |
| 396 | 396 | chf->attr.mtime.nsec == actual_attr.mtime.nsec && |
| 397 | 397 | chf->attr.inode == actual_attr.inode) |
| 398 | 398 | { |
| 399 | | os_file_close(this_file); |
| 399 | os_file_close(&this_file); |
| 400 | 400 | } else { |
| 401 | 401 | // we have to recompute the digest. |
| 402 | 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 | 411 | |
| 412 | 412 | uint8_t actual_digest[48]; |
| 413 | 413 | if ((err = hash_file(actual_digest, this_file, nullptr))) { |
| 414 | | os_file_close(this_file); |
| 415 | | os_file_close(ch->manifest_file); |
| 414 | os_file_close(&this_file); |
| 415 | os_file_close(&ch->manifest_file); |
| 416 | 416 | return err; |
| 417 | 417 | } |
| 418 | | os_file_close(this_file); |
| 418 | os_file_close(&this_file); |
| 419 | 419 | if (memcmp(chf->bin_digest, actual_digest, 48) != 0) { |
| 420 | 420 | memcpy(chf->bin_digest, actual_digest, 48); |
| 421 | 421 | // keep going until we have the input file digests |
| ... | ... | @@ -433,12 +433,12 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 433 | 433 | CacheHashFile *chf = &ch->files.at(file_i); |
| 434 | 434 | if ((err = populate_file_hash(ch, chf, nullptr))) { |
| 435 | 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 | 437 | return ErrorCacheUnavailable; |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | if (return_code != ErrorNone) { |
| 441 | | os_file_close(ch->manifest_file); |
| 441 | os_file_close(&ch->manifest_file); |
| 442 | 442 | } |
| 443 | 443 | return return_code; |
| 444 | 444 | } |
| ... | ... | @@ -453,7 +453,7 @@ Error cache_add_file_fetch(CacheHash *ch, Buf *resolved_path, Buf *contents) { |
| 453 | 453 | CacheHashFile *chf = ch->files.add_one(); |
| 454 | 454 | chf->path = resolved_path; |
| 455 | 455 | if ((err = populate_file_hash(ch, chf, contents))) { |
| 456 | | os_file_close(ch->manifest_file); |
| 456 | os_file_close(&ch->manifest_file); |
| 457 | 457 | return err; |
| 458 | 458 | } |
| 459 | 459 | |
| ... | ... | @@ -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 | |