db: avoid iterating bounded from empty slice (fix #1401) (#1408)

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1408
Co-authored-by: Alex Auvolat <lx@deuxfleurs.fr>
Co-committed-by: Alex Auvolat <lx@deuxfleurs.fr>
This commit is contained in:
Alex Auvolat
2026-04-16 16:33:28 +00:00
committed by Alex
parent 854280e957
commit 02d5e67698
+7 -3
View File
@@ -222,9 +222,13 @@ impl Tree {
}
#[inline]
pub fn get_gt<T: AsRef<[u8]>>(&self, from: T) -> Result<Option<(Value, Value)>> {
self.range((Bound::Excluded(from), Bound::Unbounded))?
.next()
.transpose()
if from.as_ref().is_empty() {
self.iter()?.next().transpose()
} else {
self.range((Bound::Excluded(from), Bound::Unbounded))?
.next()
.transpose()
}
}
/// Returns the old value if there was one