binarystore: Don't store max_size
It never actually gets used when it is read, it is always immediately
discarded.
Change-Id: Ib4c6c4ee746a77f0b8704e5d4cf26d78415b9b16
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/binarystore.hpp b/include/binarystore.hpp
index aa83714..3b5e1a8 100644
--- a/include/binarystore.hpp
+++ b/include/binarystore.hpp
@@ -49,10 +49,6 @@
file_(std::move(file)), maxSize(maxSize)
{
blob_.set_blob_base_id(baseBlobId_);
- if (maxSize)
- {
- blob_.set_max_size_bytes(*maxSize);
- }
}
BinaryStore(std::unique_ptr<SysFile> file, bool readOnly = false,
@@ -60,10 +56,6 @@
readOnly_{readOnly},
file_(std::move(file)), maxSize(maxSize)
{
- if (maxSize)
- {
- blob_.set_max_size_bytes(*maxSize);
- }
}
~BinaryStore() = default;
diff --git a/proto/binaryblob.proto b/proto/binaryblob.proto
index ceb7735..e4b9b8b 100644
--- a/proto/binaryblob.proto
+++ b/proto/binaryblob.proto
@@ -11,5 +11,6 @@
message BinaryBlobBase {
optional string blob_base_id = 1; // Common parent path of contained blobs
repeated BinaryBlob blobs = 2;
- optional uint32 max_size_bytes = 3;
+ reserved "max_size_bytes";
+ reserved 3;
}
diff --git a/src/binarystore.cpp b/src/binarystore.cpp
index c69a653..31a2b61 100644
--- a/src/binarystore.cpp
+++ b/src/binarystore.cpp
@@ -96,16 +96,6 @@
* and is a valid case to handle. Simply init an empty binstore. */
commitState_ = CommitState::Uninitialized;
}
-
- // The new max size takes priority
- if (maxSize)
- {
- blob_.set_max_size_bytes(*maxSize);
- }
- else
- {
- blob_.clear_max_size_bytes();
- }
}
catch (const std::system_error& e)
{
diff --git a/test/binarystore_unittest.cpp b/test/binarystore_unittest.cpp
index 5b618e3..8103d6f 100644
--- a/test/binarystore_unittest.cpp
+++ b/test/binarystore_unittest.cpp
@@ -37,13 +37,11 @@
" data:\"" +
blobData +
"\""
- "}] "
- "max_size_bytes: 64";
+ "}]";
const std::string smallInputProto = "blob_base_id: \"/s/test\""
"blobs: [{ "
" blob_id: \"/s/test/0\""
- "}] "
- "max_size_bytes: 64";
+ "}]";
class SysFileBuf : public binstore::SysFile
{
@@ -216,15 +214,15 @@
EXPECT_TRUE(store->openOrCreateBlob(
"/s/test/0", blobs::OpenFlags::write | blobs::OpenFlags::read));
- // Current size 24(blob_ + max_size) + 8(size var) = 32
+ // Current size 22(blob_) + 8(size var) = 30
EXPECT_TRUE(store->write(
- 0, writeData)); // 44 = 32(existing) + 10 (data) + 2 (blob_id '/0')
+ 0, writeData)); // 42 = 30(existing) + 10 (data) + 2 (blob_id '/0')
EXPECT_FALSE(
- store->write(10, writeData)); // 54 = 44 (existing) + 10 (new data)
+ store->write(10, writeData)); // 52 = 42 (existing) + 10 (new data)
EXPECT_FALSE(
- store->write(5, writeData)); // 49 = 44 (existing) + 5 (new data)
+ store->write(7, writeData)); // 49 = 42 (existing) + 7 (new data)
EXPECT_TRUE(
- store->write(4, writeData)); // 48 = 44 (existing) + 4 (new data)
+ store->write(6, writeData)); // 48 = 42 (existing) + 6 (new data)
}
TEST_F(BinaryStoreTest, TestCreateFromConfigExceedMaxSize)