| ... | @@ -441,18 +441,13 @@ static Error write_manifest_file(CacheHash *ch) { | ... | @@ -441,18 +441,13 @@ static Error write_manifest_file(CacheHash *ch) { |
| 441 | } | 441 | } |
| 442 | | 442 | |
| 443 | Error cache_final(CacheHash *ch, Buf *out_digest) { | 443 | Error cache_final(CacheHash *ch, Buf *out_digest) { |
| 444 | Error err; | | |
| 445 | | | |
| 446 | assert(ch->manifest_file_path != nullptr); | 444 | assert(ch->manifest_file_path != nullptr); |
| 447 | | 445 | |
| 448 | if (ch->manifest_dirty) { | | |
| 449 | if ((err = write_manifest_file(ch))) { | | |
| 450 | fprintf(stderr, "Warning: Unable to write cache file '%s': %s\n", | | |
| 451 | buf_ptr(ch->manifest_file_path), err_str(err)); | | |
| 452 | } | | |
| 453 | } | | |
| 454 | // We don't close the manifest file yet, because we want to | 446 | // We don't close the manifest file yet, because we want to |
| 455 | // keep it locked until the API user is done using it. | 447 | // keep it locked until the API user is done using it. |
| | 448 | // We also don't write out the manifest yet, because until |
| | 449 | // cache_release is called we still might be working on creating |
| | 450 | // the artifacts to cache. |
| 456 | | 451 | |
| 457 | uint8_t bin_digest[48]; | 452 | uint8_t bin_digest[48]; |
| 458 | int rc = blake2b_final(&ch->blake, bin_digest, 48); | 453 | int rc = blake2b_final(&ch->blake, bin_digest, 48); |
| ... | @@ -465,5 +460,15 @@ Error cache_final(CacheHash *ch, Buf *out_digest) { | ... | @@ -465,5 +460,15 @@ Error cache_final(CacheHash *ch, Buf *out_digest) { |
| 465 | | 460 | |
| 466 | void cache_release(CacheHash *ch) { | 461 | void cache_release(CacheHash *ch) { |
| 467 | assert(ch->manifest_file_path != nullptr); | 462 | assert(ch->manifest_file_path != nullptr); |
| | 463 | |
| | 464 | Error err; |
| | 465 | |
| | 466 | if (ch->manifest_dirty) { |
| | 467 | if ((err = write_manifest_file(ch))) { |
| | 468 | fprintf(stderr, "Warning: Unable to write cache file '%s': %s\n", |
| | 469 | buf_ptr(ch->manifest_file_path), err_str(err)); |
| | 470 | } |
| | 471 | } |
| | 472 | |
| 468 | os_file_close(ch->manifest_file); | 473 | os_file_close(ch->manifest_file); |
| 469 | } | 474 | } |