Skip to content

Commit

Permalink
Fixing datagen error with zip files (#3434)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed May 16, 2023
1 parent 8ba9224 commit fec896a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions provider/datagen/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::options::Options;
use crate::transform::cldr::source::CldrCache;
pub use crate::transform::cldr::source::CoverageLevel;
use elsa::sync::FrozenMap;
use icu_provider::DataError;
use icu_provider::prelude::*;
use std::any::Any;
use std::collections::{BTreeMap, HashSet};
use std::fmt::Debug;
Expand Down Expand Up @@ -360,7 +360,9 @@ impl AbstractFs {
std::fs::read(&root)?,
))
.map_err(|e| {
DataError::custom("Zip").with_display_context(&e)
DataError::custom("Invalid ZIP file")
.with_display_context(&e)
.with_path_context(&root)
})?))))
}
}
Expand Down Expand Up @@ -478,8 +480,13 @@ impl AbstractFs {
.cached_path(resource)
.map_err(|e| DataError::custom("Download").with_display_context(&e))?
};
*lock = Ok(ZipArchive::new(Cursor::new(std::fs::read(root)?))
.map_err(|e| DataError::custom("Zip").with_display_context(&e))?);
*lock = Ok(
ZipArchive::new(Cursor::new(std::fs::read(&root)?)).map_err(|e| {
DataError::custom("Invalid ZIP file")
.with_display_context(&e)
.with_path_context(&root)
})?,
);
}
Ok(())
}
Expand All @@ -502,7 +509,8 @@ impl AbstractFs {
.unwrap() // init called
.by_name(path)
.map_err(|e| {
DataError::custom("Zip")
DataErrorKind::Io(std::io::ErrorKind::NotFound)
.into_error()
.with_display_context(&e)
.with_display_context(path)
})?
Expand Down

0 comments on commit fec896a

Please sign in to comment.