diff options
author | Etienne Pierre-doray <etiennep@chromium.org> | 2021-10-28 21:16:04 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-10-28 14:31:23 -0700 |
commit | b90a947429fdce96b1d684b9a7af9683cb4a13c1 (patch) | |
tree | 333e034b74f5ec4cfb1be1600c4d1a061afbb3bc /zucchini_integration.cc | |
parent | aff408603b3db5b7974c522db2ad8c5ce2a0f3c1 (diff) | |
download | zucchini-b90a947429fdce96b1d684b9a7af9683cb4a13c1.tar.gz |
[Zucchini]: Add patch version.
This is a breaking change to zucchini patch format:
Zucchini 1.0, see changelog.
Add major/minor patch-wide version, and element version.
Also add VerifyPatch() API and command line option to verify
patch compatibility.
Design: go/zucchini-versions
Bug: 1231882
Change-Id: I19f1fbe2ee866c23f0814ffe6a912fb72812edbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3140224
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936096}
NOKEYCHECK=True
GitOrigin-RevId: 559d77a9741428a48add017d389d104e431e6de7
Diffstat (limited to 'zucchini_integration.cc')
-rw-r--r-- | zucchini_integration.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zucchini_integration.cc b/zucchini_integration.cc index ff7e792..bf28b3c 100644 --- a/zucchini_integration.cc +++ b/zucchini_integration.cc @@ -146,6 +146,22 @@ status::Code ApplyCommon(base::File old_file, return status::kStatusSuccess; } +status::Code VerifyPatchCommon(base::File patch_file, + base::FilePath patch_name) { + MappedFileReader mapped_patch(std::move(patch_file)); + if (mapped_patch.HasError()) { + LOG(ERROR) << "Error with file " << patch_name.value() << ": " + << mapped_patch.error(); + return status::kStatusFileReadError; + } + auto patch_reader = EnsemblePatchReader::Create(mapped_patch.region()); + if (!patch_reader.has_value()) { + LOG(ERROR) << "Error reading patch header."; + return status::kStatusPatchReadError; + } + return status::kStatusSuccess; +} + } // namespace status::Code Generate(base::File old_file, @@ -206,4 +222,15 @@ status::Code Apply(const base::FilePath& old_path, std::move(new_file), file_names, force_keep); } +status::Code VerifyPatch(base::File patch_file) { + return VerifyPatchCommon(std::move(patch_file), base::FilePath()); +} + +status::Code VerifyPatch(const base::FilePath& patch_path) { + using base::File; + File patch_file(patch_path, File::FLAG_OPEN | File::FLAG_READ | + base::File::FLAG_SHARE_DELETE); + return VerifyPatchCommon(std::move(patch_file), patch_path); +} + } // namespace zucchini |