Skip to content

Commit 6b3c3b0

Browse files
committed
replace panic with error when decoding compression from archive index
1 parent 02c5cf1 commit 6b3c3b0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/storage/archive_index.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,16 @@ fn find_in_sqlite_index(conn: &Connection, search_for: &str) -> Result<Option<Fi
197197

198198
stmt.query_row((search_for,), |row| {
199199
let compression: i32 = row.get(2)?;
200+
200201
Ok(FileInfo {
201202
range: row.get(0)?..=row.get(1)?,
202-
compression: compression.try_into().expect("invalid compression value"),
203+
compression: compression.try_into().map_err(|value| {
204+
rusqlite::Error::FromSqlConversionFailure(
205+
2,
206+
rusqlite::types::Type::Integer,
207+
format!("invalid compression algorithm '{}' in database", value).into(),
208+
)
209+
})?,
203210
})
204211
})
205212
.optional()

0 commit comments

Comments
 (0)