Skip to content

Commit

Permalink
Fix S3Storage not loading chunks for networks started not from 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Sep 10, 2023
1 parent 0ef5d58 commit 9b9c4f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/router/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ impl Storage for S3Storage {
let tops = self.ls(prefix)?;

let mut top: Option<String> = None;
for item in tops.iter().rev() {
let block_num = item.parse::<u32>().map_err(|err| err.to_string())?;
if block_num <= next_block {
top = Some(item.clone());
break;
if tops.len() == 1 {
top = Some(tops[0].clone())
} else {
for item in tops.iter().rev() {
let block_num = item.parse::<u32>().map_err(|err| err.to_string())?;
if block_num <= next_block {
top = Some(item.clone());
break;
}
}
}

Expand All @@ -48,7 +52,7 @@ impl Storage for S3Storage {
for chunk in top_chunks {
let chunk = DataChunk::from_str(&chunk)
.map_err(|_| format!("invalid chunk name - {}", &chunk))?;
if chunk.first_block() == next_block {
if chunk.first_block() == next_block || next_block == 0 {
next_chunk = Some(chunk);
break;
}
Expand Down

0 comments on commit 9b9c4f6

Please sign in to comment.