Skip to content

Commit

Permalink
AWS S3 binary cache miss should not issue warning
Browse files Browse the repository at this point in the history
  • Loading branch information
petamas committed May 9, 2024
1 parent 03db8e2 commit c3c6df5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vcpkg/binarycaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,21 @@ namespace
cmd.string_arg("--no-sign-request");
}

return flatten(cmd_execute_and_capture_output(cmd), Tools::AWSCLI).map(unit_to_cache_hit);
auto maybe_exit = cmd_execute_and_capture_output(cmd);
// When the file is not found, "aws s3 ls" prints nothing, and returns exit code 1.
// flatten() would treat this as an error, but we want to treat it as a (silent) cache miss instead.
// See https://github.com/aws/aws-cli/issues/5544 for the related aws-cli bug report.
if (auto exit = maybe_exit.get())
{
// We want to return CacheResult::miss even if aws-cli starts to return success
const bool success_or_exit_code_1 = exit->exit_code == 0 || exit->exit_code == 1;
const bool output_is_empty = Strings::trim(exit->output) == "";
if (success_or_exit_code_1 && output_is_empty)
{
return CacheResult::miss;
}
}
return flatten(maybe_exit, Tools::AWSCLI).map(unit_to_cache_hit);
}

ExpectedL<CacheResult> download_file(StringView object, const Path& archive) const override
Expand Down

0 comments on commit c3c6df5

Please sign in to comment.