binarystore: Enable maxBinarySize Feature
Fail on write() and commit() if the result will exceed the max size.
Enabled by adding the max_binary_size to the proto buffer. The new one
takes priority and will replace existing one even if it already exists.
The `max_binary_size` is the size of the total data including the size
header. It is calculated with
```
blob_.SerializeAsString().size() +
sizeof(boost::endian::little_uint64_t)
```
Change-Id: I28a4c7a25fa066c11510b51cdfce27df4e09d3b5
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/main.cpp b/main.cpp
index 7c39eaf..5cf6c10 100644
--- a/main.cpp
+++ b/main.cpp
@@ -71,7 +71,7 @@
config.offsetBytes);
handler->addNewBinaryStore(binstore::BinaryStore::createFromConfig(
- config.blobBaseId, std::move(file)));
+ config.blobBaseId, std::move(file), config.maxSizeBytes));
}
return handler;