Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ll-core/src/cse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl CSE {

if !res.status().is_success() {

return Err(new_err!(format!("Error downloading file: {}", res.status())))
return Err(new_err!(format!("Error downloading file: {} from {}", res.status(), url)))

} else if res_header != "application/x-zip" {

Expand Down
16 changes: 8 additions & 8 deletions ll-core/src/format/extractors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ pub(super) fn generic_extractor(format: &Format, files: &mut Files, file_path: S

}

if file_path_lower.contains(&format.match_path.to_lowercase()) {

let path = PathBuf::from(file_path);
let base_name = path.file_name().unwrap().to_string_lossy().to_string();
let mut f_data = Vec::<u8>::new();
item.read_to_end(&mut f_data)?;
files.insert(base_name, f_data);

let path = PathBuf::from(file_path);
for paths_to_extract in &format.match_path {
if file_path_lower.contains(paths_to_extract.to_lowercase().as_str()) {
let base_name = path.file_name().unwrap().to_string_lossy().to_string();
let mut f_data = Vec::<u8>::new();
item.read_to_end(&mut f_data)?;
files.insert(base_name, f_data);
}
}

Ok(())
Expand Down
12 changes: 6 additions & 6 deletions ll-core/src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Format {
pub name: String,
pub ecad: ECAD,
pub create_folder: bool,
match_path: &'static str,
match_path: Vec<&'static str>,
ignore: Vec<&'static str>
}

Expand All @@ -35,35 +35,35 @@ impl Format {
name: f,
ecad: ECAD::D3,
create_folder: true,
match_path: "3D",
match_path: vec!["3D"],
ignore: vec![]
},
"eagle" => Self {
name: f,
ecad: ECAD::EAGLE,
create_folder: false,
match_path: "EAGLE",
match_path: vec!["EAGLE/", "/3D/"],
ignore: vec!["Readme.html"]
},
"easyeda" => Self {
name: f,
ecad: ECAD::EASYEDA,
create_folder: false,
match_path: "EasyEDA",
match_path: vec!["EasyEDA/", "/3D/"],
ignore: vec!["Readme.html"]
},
"kicad" => Self {
name: f,
ecad: ECAD::KICAD,
create_folder: true,
match_path: "KiCad",
match_path: vec!["KiCad/", "/3D/"],
ignore: vec![]
},
"zip" => Self {
name: f,
ecad: ECAD::ZIP,
create_folder: false,
match_path: "",
match_path: vec![""],
ignore: vec![]
},
_ => {
Expand Down
20 changes: 14 additions & 6 deletions ll-core/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,20 @@ impl Watcher {

}

fn handle_file<P: Into<PathBuf>>(&self, path: P) -> LLResult<String> {

let epw = Epw::from_file(path)?;
let res = &self.cse.get(epw)?;
res.save()

fn handle_file(&self, path: &PathBuf) -> LLResult<String> {
let extension = path.extension().and_then(|ext| { ext.to_str() });
match extension {
Some(s) => if s.eq_ignore_ascii_case("zip") {
let epw = Epw::from_file(path)?;
let res = &self.cse.get(epw)?;
res.save()
} else {
Err(new_err!(format!("=> Ignoring non-zip: {}", path.to_str().unwrap())))
}
None => {
Err(new_err!(format!("=r Ignoring: {}", path.to_str().unwrap())))
}
}
}

}
Expand Down