Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
storage: remove unused parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Smirnov <[email protected]>
  • Loading branch information
Eugene Smirnov committed Feb 26, 2020
1 parent 864bcf0 commit f4db090
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/libaktualizr/package_manager/debianmanager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
std::stringstream("ab") >> *fhandle;
fhandle->wcommit();

Expand All @@ -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<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
std::stringstream("ab") >> *fhandle;
fhandle->wcommit();

Expand Down
8 changes: 4 additions & 4 deletions src/libaktualizr/package_manager/packagemanagerfake_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ 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);
whandle->wcommit();
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);
Expand Down
4 changes: 2 additions & 2 deletions src/libaktualizr/package_manager/packagemanagerinterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<DownloadMetaStruct>(target, progress_cb, token);
ds->fhandle = storage_->allocateTargetFile(false, target);
ds->fhandle = storage_->allocateTargetFile(target);
continue;
}

Expand Down
3 changes: 1 addition & 2 deletions src/libaktualizr/storage/invstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ class INvStorage {
virtual boost::optional<std::pair<size_t, std::string>> checkTargetFile(const Uptane::Target& target) const = 0;

// Incremental file API
virtual std::unique_ptr<StorageTargetWHandle> allocateTargetFile(bool from_director,
const Uptane::Target& target) = 0;
virtual std::unique_ptr<StorageTargetWHandle> allocateTargetFile(const Uptane::Target& target) = 0;

virtual std::unique_ptr<StorageTargetRHandle> openTargetFile(const Uptane::Target& target) = 0;
virtual std::vector<Uptane::Target> getTargetFiles() = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/libaktualizr/storage/sqlstorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1796,8 +1796,7 @@ class SQLTargetWHandle : public StorageTargetWHandle {
std::ofstream stream_;
};

std::unique_ptr<StorageTargetWHandle> SQLStorage::allocateTargetFile(bool from_director, const Uptane::Target& target) {
(void)from_director;
std::unique_ptr<StorageTargetWHandle> SQLStorage::allocateTargetFile(const Uptane::Target& target) {
return std::unique_ptr<StorageTargetWHandle>(new SQLTargetWHandle(*this, target));
}

Expand Down
2 changes: 1 addition & 1 deletion src/libaktualizr/storage/sqlstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SQLStorage : public SQLStorageBase, public INvStorage {

bool checkAvailableDiskSpace(uint64_t required_bytes) const override;

std::unique_ptr<StorageTargetWHandle> allocateTargetFile(bool from_director, const Uptane::Target& target) override;
std::unique_ptr<StorageTargetWHandle> allocateTargetFile(const Uptane::Target& target) override;
std::unique_ptr<StorageTargetRHandle> openTargetFile(const Uptane::Target& target) override;
boost::optional<std::pair<size_t, std::string>> checkTargetFile(const Uptane::Target& target) const override;
std::vector<Uptane::Target> getTargetFiles() override;
Expand Down
12 changes: 6 additions & 6 deletions src/libaktualizr/storage/storage_common_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ TEST(storage, store_target) {

// write
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
const uint8_t wb[] = "ab";
fhandle->wfeed(wb, 1);
fhandle->wfeed(wb + 1, 1);
Expand All @@ -492,7 +492,7 @@ TEST(storage, store_target) {

// write again
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
const uint8_t wb[] = "ab";
fhandle->wfeed(wb, 1);
fhandle->wfeed(wb + 1, 1);
Expand All @@ -508,7 +508,7 @@ TEST(storage, store_target) {

// write stream
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
std::stringstream("ab") >> *fhandle;
}

Expand Down Expand Up @@ -539,7 +539,7 @@ TEST(storage, list_remove_targets) {

// write
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
const uint8_t wb[] = "ab";
fhandle->wfeed(wb, 1);
fhandle->wfeed(wb + 1, 1);
Expand Down Expand Up @@ -623,7 +623,7 @@ TEST(storage, checksum) {

// write target1
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target1);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target1);
const uint8_t wb[] = "ab";
fhandle->wfeed(wb, 2);
fhandle->wcommit();
Expand Down Expand Up @@ -654,7 +654,7 @@ TEST(storage, partial) {

// write partial target
{
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(false, target);
std::unique_ptr<StorageTargetWHandle> fhandle = storage->allocateTargetFile(target);
const uint8_t wb[] = "a";
fhandle->wfeed(wb, 1);
fhandle->wcommit();
Expand Down
10 changes: 5 additions & 5 deletions src/libaktualizr/uptane/uptane_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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<uint8_t *>(content), length - 1), length - 1);
whandle->wcommit();

Expand All @@ -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<uint8_t *>(content), length), length);
whandle->wcommit();

Expand Down

0 comments on commit f4db090

Please sign in to comment.