Skip to content

Commit 9f1ff9e

Browse files
committed
update zip usage after breaking change in library
1 parent 9a3beaa commit 9f1ff9e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

crates/lib/docs_rs_storage/src/archive_index.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::types::FileRange;
2-
use anyhow::{Context as _, Result, bail};
2+
use anyhow::{Context as _, Result, anyhow, bail};
33
use docs_rs_types::CompressionAlgorithm;
44
use itertools::Itertools as _;
55
use sqlx::{Acquire as _, QueryBuilder, Row as _, Sqlite};
@@ -96,17 +96,20 @@ pub(crate) async fn create<R: io::Read + io::Seek, P: AsRef<Path> + std::fmt::De
9696

9797
let entry = archive.by_index(i)?;
9898

99-
let start = entry.data_start() as i64;
100-
let end = (entry.data_start() + entry.compressed_size() - 1) as i64;
99+
let start = entry
100+
.data_start()
101+
.ok_or_else(|| anyhow!("missing data_start in zip derectory"))?;
102+
103+
let end = start + entry.compressed_size() - 1;
101104
let compression_raw = match entry.compression() {
102105
zip::CompressionMethod::Bzip2 => compression_bzip,
103106
c => bail!("unsupported compression algorithm {} in zip-file", c),
104107
};
105108

106109
insert_stmt.push_values([()], |mut b, _| {
107110
b.push_bind(entry.name())
108-
.push_bind(start)
109-
.push_bind(end)
111+
.push_bind(start as i64)
112+
.push_bind(end as i64)
110113
.push_bind(compression_raw);
111114
});
112115
insert_stmt

0 commit comments

Comments
 (0)