Skip to content

Commit

Permalink
verify at least one image is exist
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Jan 3, 2025
1 parent a17c5fc commit c351153
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions martin/src/cog/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub enum CogError {
#[error("Requested zoom level {0} from file {1} is out of range. Possible zoom levels are {2} to {3}")]
ZoomOutOfRange(u8, PathBuf, u8, u8),

#[error("Couldn't find any image in the tiff file: {0}")]
NoImagesFound(PathBuf),

#[error("Couldn't seek to ifd number {1} (0 based indexing) in tiff file {2}: {0}")]
IfdSeekFailed(TiffError, usize, PathBuf),

Expand Down
4 changes: 4 additions & 0 deletions martin/src/cog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ fn get_meta(path: &PathBuf) -> Result<Meta, FileError> {
zoom_and_tile_across_down.insert(zoom, (tiles_across, tiles_down));
}

if images_ifd.is_empty() {
Err(CogError::NoImagesFound(path.clone()))?;
}

Ok(Meta {
min_zoom: 0,
max_zoom: images_ifd.len() as u8 - 1,
Expand Down

0 comments on commit c351153

Please sign in to comment.