Skip to content

Commit 54d1337

Browse files
committed
f More debug_asserts for empty keys
1 parent 135de93 commit 54d1337

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning-persister/src/fs_store.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ impl FilesystemStore {
5555
impl KVStore for FilesystemStore {
5656
fn read(&self, namespace: &str, key: &str) -> std::io::Result<Vec<u8>> {
5757
if key.is_empty() {
58+
debug_assert!(false, "Failed to read {}/{}: key may not be empty.",
59+
PrintableString(namespace), PrintableString(key));
5860
let msg = format!("Failed to read {}/{}: key may not be empty.",
5961
PrintableString(namespace), PrintableString(key));
6062
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
@@ -89,6 +91,8 @@ impl KVStore for FilesystemStore {
8991

9092
fn write(&self, namespace: &str, key: &str, buf: &[u8]) -> std::io::Result<()> {
9193
if key.is_empty() {
94+
debug_assert!(false, "Failed to write {}/{}: key may not be empty.",
95+
PrintableString(namespace), PrintableString(key));
9296
let msg = format!("Failed to write {}/{}: key may not be empty.",
9397
PrintableString(namespace), PrintableString(key));
9498
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
@@ -174,6 +178,8 @@ impl KVStore for FilesystemStore {
174178

175179
fn remove(&self, namespace: &str, key: &str) -> std::io::Result<()> {
176180
if key.is_empty() {
181+
debug_assert!(false, "Failed to remove {}/{}: key may not be empty.",
182+
PrintableString(namespace), PrintableString(key));
177183
let msg = format!("Failed to remove {}/{}: key may not be empty.",
178184
PrintableString(namespace), PrintableString(key));
179185
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));

0 commit comments

Comments
 (0)