feat: multiline logging
This commit is contained in:
parent
401efe3862
commit
9a852ee88e
7 changed files with 75 additions and 38 deletions
|
@ -7,15 +7,15 @@ use regex::Regex;
|
|||
pub enum PackageIdentifierError {
|
||||
InvalidPackageLocator(String),
|
||||
InvalidURI(String),
|
||||
InvalidPath(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PackageIdentifierError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
PackageIdentifierError::InvalidPackageLocator(s) => {
|
||||
write!(f, "Invalid package locator: {}", s)
|
||||
}
|
||||
PackageIdentifierError::InvalidPackageLocator(s) => write!(f, "Invalid package locator: {}", s),
|
||||
PackageIdentifierError::InvalidURI(s) => write!(f, "Invalid URI: {}", s),
|
||||
PackageIdentifierError::InvalidPath(s) => write!(f, "Invalid path: {}", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,18 @@ impl FromStr for PackageIdentifier {
|
|||
return Err(PackageIdentifierError::InvalidURI(s.to_string()));
|
||||
}
|
||||
Ok(PackageIdentifier::URI(s.to_string()))
|
||||
} else if std::path::Path::new(s).exists() {
|
||||
} else if s.starts_with("/")
|
||||
|| s.starts_with("./")
|
||||
|| s.starts_with("../")
|
||||
|| s.starts_with("~/")
|
||||
{
|
||||
let path = std::path::Path::new(s);
|
||||
if s.ends_with("/")
|
||||
|| !path.exists()
|
||||
|| path.is_dir()
|
||||
{
|
||||
return Err(PackageIdentifierError::InvalidPath(s.to_string()));
|
||||
}
|
||||
return Ok(PackageIdentifier::Path(s.to_string()));
|
||||
} else {
|
||||
let pl = match PackageLocator::from_str(s) {
|
||||
|
|
|
@ -37,8 +37,8 @@ pub enum InstallError {
|
|||
impl ToString for InstallError {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
InstallError::BuildError(e) => format!("Build error: {}", e),
|
||||
InstallError::BinError(e) => format!("Bin error: {}", e),
|
||||
InstallError::BuildError(e) => format!("Build error: \n{}", e),
|
||||
InstallError::BinError(e) => format!("Bin error: \n{}", e),
|
||||
InstallError::InvalidManifest => "Invalid manifest".to_string(),
|
||||
InstallError::Generic => "Install error".to_string(),
|
||||
}
|
||||
|
|
|
@ -38,7 +38,10 @@ impl PackageInstaller {
|
|||
return Err(BinError::UnpackError("package has no data".to_string()));
|
||||
}
|
||||
if std::path::Path::new(&path).exists() {
|
||||
return Err(BinError::UnpackError("path already exists".to_string()));
|
||||
return Err(BinError::UnpackError(format!(
|
||||
"path already exists: {}",
|
||||
path
|
||||
)));
|
||||
}
|
||||
tar::Archive::new(self.pkgfile.data.as_slice())
|
||||
.unpack(&path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue