mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
Handle unwraps
This commit is contained in:
parent
82bac674e9
commit
953de07b56
@ -113,10 +113,17 @@ impl CLI for AddCommand {
|
||||
let bytes = response.bytes()?;
|
||||
let reader = std::io::Cursor::new(bytes);
|
||||
|
||||
let mut zip_arhive = zip::ZipArchive::new(reader).unwrap();
|
||||
let mut zip_arhive = match zip::ZipArchive::new(reader) {
|
||||
Ok(zip) => zip,
|
||||
Err(error) => return Err(AddError(ZipError(error.to_string().into()))),
|
||||
};
|
||||
|
||||
for i in 0..zip_arhive.len() {
|
||||
let file = zip_arhive.by_index(i).unwrap();
|
||||
let file = match zip_arhive.by_index(i) {
|
||||
Ok(file) => file,
|
||||
Err(error) => return Err(AddError(ZipError(error.to_string().into()))),
|
||||
};
|
||||
|
||||
let file_name = file.name();
|
||||
|
||||
let mut file_path = path.clone();
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
cli::*,
|
||||
cli_types::*,
|
||||
commands::LoginCommand,
|
||||
credentials::read_token,
|
||||
credentials::{read_token, PACKAGE_MANAGER_URL},
|
||||
errors::{
|
||||
commands::PublishError::{ConnectionUnavalaible, PackageNotPublished},
|
||||
CLIError,
|
||||
@ -22,7 +22,6 @@ use reqwest::{
|
||||
use serde::Deserialize;
|
||||
use std::{convert::TryFrom, env::current_dir};
|
||||
|
||||
const PACKAGE_MANAGER_URL: &str = "https://apm-backend-dev.herokuapp.com/";
|
||||
const PUBLISH_URL: &str = "api/package/publish";
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -7,4 +7,7 @@ pub enum AddError {
|
||||
|
||||
#[error("missing author or package name")]
|
||||
MissingAuthorOrPackageName,
|
||||
|
||||
#[error("{:?}", _0)]
|
||||
ZipError(OsString),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user