diff --git a/src/libaktualizr/package_manager/debianmanager_test.cc b/src/libaktualizr/package_manager/debianmanager_test.cc index 209fd4f64e..d76e34f240 100644 --- a/src/libaktualizr/package_manager/debianmanager_test.cc +++ b/src/libaktualizr/package_manager/debianmanager_test.cc @@ -32,7 +32,7 @@ TEST(PackageManagerFactory, Debian_Install_Good) { target_json_test["length"] = 2; Uptane::Target target_test("test.deb", target_json_test); storage->savePrimaryInstalledVersion(target_test, InstalledVersionUpdateMode::kCurrent); - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); std::stringstream("ab") >> *fhandle; fhandle->wcommit(); @@ -55,7 +55,7 @@ TEST(PackageManagerFactory, Debian_Install_Bad) { target_json["custom"]["ecuIdentifiers"]["primary_serial"]["hardwareId"] = "primary_hwid"; Uptane::Target target("bad.deb", target_json); - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); std::stringstream("ab") >> *fhandle; fhandle->wcommit(); diff --git a/src/libaktualizr/package_manager/packagemanagerfake_test.cc b/src/libaktualizr/package_manager/packagemanagerfake_test.cc index 9b0b067f7b..aa8ee18c28 100644 --- a/src/libaktualizr/package_manager/packagemanagerfake_test.cc +++ b/src/libaktualizr/package_manager/packagemanagerfake_test.cc @@ -43,7 +43,7 @@ TEST(PackageManagerFake, Verify) { EXPECT_EQ(fakepm.verifyTarget(target), TargetStatus::kNotFound); // Target has a bad hash. - auto whandle = storage->allocateTargetFile(false, target); + auto whandle = storage->allocateTargetFile(target); uint8_t content_bad[length + 1]; memset(content_bad, 0, length + 1); EXPECT_EQ(whandle->wfeed(content_bad, length), length); @@ -51,19 +51,19 @@ TEST(PackageManagerFake, Verify) { EXPECT_EQ(fakepm.verifyTarget(target), TargetStatus::kHashMismatch); // Target is oversized. - whandle = storage->allocateTargetFile(false, target); + whandle = storage->allocateTargetFile(target); EXPECT_EQ(whandle->wfeed(content_bad, length + 1), length + 1); whandle->wcommit(); EXPECT_EQ(fakepm.verifyTarget(target), TargetStatus::kOversized); // Target is incomplete. - whandle = storage->allocateTargetFile(false, target); + whandle = storage->allocateTargetFile(target); EXPECT_EQ(whandle->wfeed(content, length - 1), length - 1); whandle->wcommit(); EXPECT_EQ(fakepm.verifyTarget(target), TargetStatus::kIncomplete); // Target is good. - whandle = storage->allocateTargetFile(false, target); + whandle = storage->allocateTargetFile(target); EXPECT_EQ(whandle->wfeed(content, length), length); whandle->wcommit(); EXPECT_EQ(fakepm.verifyTarget(target), TargetStatus::kGood); diff --git a/src/libaktualizr/package_manager/packagemanagerinterface.cc b/src/libaktualizr/package_manager/packagemanagerinterface.cc index 9197aacf23..15fce04ce9 100644 --- a/src/libaktualizr/package_manager/packagemanagerinterface.cc +++ b/src/libaktualizr/package_manager/packagemanagerinterface.cc @@ -107,7 +107,7 @@ bool PackageManagerInterface::fetchTarget(const Uptane::Target& target, Uptane:: } else { // If the target was found, but is oversized or the hash doesn't match, // just start over. - ds->fhandle = storage_->allocateTargetFile(false, target); + ds->fhandle = storage_->allocateTargetFile(target); } const uint64_t required_bytes = target.length() - ds->downloaded_length; @@ -130,7 +130,7 @@ bool PackageManagerInterface::fetchTarget(const Uptane::Target& target, Uptane:: " try to download the image from the beginning: " << target_url; ds = std_::make_unique(target, progress_cb, token); - ds->fhandle = storage_->allocateTargetFile(false, target); + ds->fhandle = storage_->allocateTargetFile(target); continue; } diff --git a/src/libaktualizr/storage/invstorage.h b/src/libaktualizr/storage/invstorage.h index 71643c6b18..0e18ff6dcf 100644 --- a/src/libaktualizr/storage/invstorage.h +++ b/src/libaktualizr/storage/invstorage.h @@ -215,8 +215,7 @@ class INvStorage { virtual boost::optional> checkTargetFile(const Uptane::Target& target) const = 0; // Incremental file API - virtual std::unique_ptr allocateTargetFile(bool from_director, - const Uptane::Target& target) = 0; + virtual std::unique_ptr allocateTargetFile(const Uptane::Target& target) = 0; virtual std::unique_ptr openTargetFile(const Uptane::Target& target) = 0; virtual std::vector getTargetFiles() = 0; diff --git a/src/libaktualizr/storage/sqlstorage.cc b/src/libaktualizr/storage/sqlstorage.cc index 3340cc573f..c4129a7165 100644 --- a/src/libaktualizr/storage/sqlstorage.cc +++ b/src/libaktualizr/storage/sqlstorage.cc @@ -1796,8 +1796,7 @@ class SQLTargetWHandle : public StorageTargetWHandle { std::ofstream stream_; }; -std::unique_ptr SQLStorage::allocateTargetFile(bool from_director, const Uptane::Target& target) { - (void)from_director; +std::unique_ptr SQLStorage::allocateTargetFile(const Uptane::Target& target) { return std::unique_ptr(new SQLTargetWHandle(*this, target)); } diff --git a/src/libaktualizr/storage/sqlstorage.h b/src/libaktualizr/storage/sqlstorage.h index fe5609408b..7312b3af44 100644 --- a/src/libaktualizr/storage/sqlstorage.h +++ b/src/libaktualizr/storage/sqlstorage.h @@ -95,7 +95,7 @@ class SQLStorage : public SQLStorageBase, public INvStorage { bool checkAvailableDiskSpace(uint64_t required_bytes) const override; - std::unique_ptr allocateTargetFile(bool from_director, const Uptane::Target& target) override; + std::unique_ptr allocateTargetFile(const Uptane::Target& target) override; std::unique_ptr openTargetFile(const Uptane::Target& target) override; boost::optional> checkTargetFile(const Uptane::Target& target) const override; std::vector getTargetFiles() override; diff --git a/src/libaktualizr/storage/storage_common_test.cc b/src/libaktualizr/storage/storage_common_test.cc index 19a6ec38f1..37ffd16367 100644 --- a/src/libaktualizr/storage/storage_common_test.cc +++ b/src/libaktualizr/storage/storage_common_test.cc @@ -472,7 +472,7 @@ TEST(storage, store_target) { // write { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); const uint8_t wb[] = "ab"; fhandle->wfeed(wb, 1); fhandle->wfeed(wb + 1, 1); @@ -492,7 +492,7 @@ TEST(storage, store_target) { // write again { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); const uint8_t wb[] = "ab"; fhandle->wfeed(wb, 1); fhandle->wfeed(wb + 1, 1); @@ -508,7 +508,7 @@ TEST(storage, store_target) { // write stream { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); std::stringstream("ab") >> *fhandle; } @@ -539,7 +539,7 @@ TEST(storage, list_remove_targets) { // write { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); const uint8_t wb[] = "ab"; fhandle->wfeed(wb, 1); fhandle->wfeed(wb + 1, 1); @@ -623,7 +623,7 @@ TEST(storage, checksum) { // write target1 { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target1); + std::unique_ptr fhandle = storage->allocateTargetFile(target1); const uint8_t wb[] = "ab"; fhandle->wfeed(wb, 2); fhandle->wcommit(); @@ -654,7 +654,7 @@ TEST(storage, partial) { // write partial target { - std::unique_ptr fhandle = storage->allocateTargetFile(false, target); + std::unique_ptr fhandle = storage->allocateTargetFile(target); const uint8_t wb[] = "a"; fhandle->wfeed(wb, 1); fhandle->wcommit(); diff --git a/src/libaktualizr/uptane/uptane_test.cc b/src/libaktualizr/uptane/uptane_test.cc index d1160c49f3..2f5966dee7 100644 --- a/src/libaktualizr/uptane/uptane_test.cc +++ b/src/libaktualizr/uptane/uptane_test.cc @@ -440,7 +440,7 @@ TEST(Uptane, InstallFakeBad) { uint8_t content[length]; EXPECT_EQ(rhandle->rread(content, length), length); rhandle->rclose(); - auto whandle = storage->allocateTargetFile(false, download_result.updates[0]); + auto whandle = storage->allocateTargetFile(download_result.updates[0]); uint8_t content_bad[length + 1]; memset(content_bad, 0, length + 1); EXPECT_EQ(whandle->wfeed(content_bad, 3), 3); @@ -451,7 +451,7 @@ TEST(Uptane, InstallFakeBad) { EXPECT_EQ(install_result.dev_report.result_code, data::ResultCode::Numeric::kInternalError); // Try again with oversized data. - whandle = storage->allocateTargetFile(false, download_result.updates[0]); + whandle = storage->allocateTargetFile(download_result.updates[0]); EXPECT_EQ(whandle->wfeed(content_bad, length + 1), length + 1); whandle->wcommit(); @@ -461,7 +461,7 @@ TEST(Uptane, InstallFakeBad) { // Try again with equally long data to make sure the hash check actually gets // triggered. - whandle = storage->allocateTargetFile(false, download_result.updates[0]); + whandle = storage->allocateTargetFile(download_result.updates[0]); EXPECT_EQ(whandle->wfeed(content_bad, length), length); whandle->wcommit(); @@ -470,7 +470,7 @@ TEST(Uptane, InstallFakeBad) { EXPECT_EQ(install_result.dev_report.result_code, data::ResultCode::Numeric::kInternalError); // Try with the real data, but incomplete. - whandle = storage->allocateTargetFile(false, download_result.updates[0]); + whandle = storage->allocateTargetFile(download_result.updates[0]); EXPECT_EQ(whandle->wfeed(reinterpret_cast(content), length - 1), length - 1); whandle->wcommit(); @@ -479,7 +479,7 @@ TEST(Uptane, InstallFakeBad) { EXPECT_EQ(install_result.dev_report.result_code, data::ResultCode::Numeric::kInternalError); // Restore the original data to the file so that verification succeeds. - whandle = storage->allocateTargetFile(false, download_result.updates[0]); + whandle = storage->allocateTargetFile(download_result.updates[0]); EXPECT_EQ(whandle->wfeed(reinterpret_cast(content), length), length); whandle->wcommit();