Improve chrooting error messages

main
trivernis 2 years ago
parent d89ce35495
commit 6d538c70ad
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: DFFFCC2C7A02DB45

@ -112,7 +112,7 @@ pub enum ChrootError {
#[diagnostic(code(trm::chroot::mount))] #[diagnostic(code(trm::chroot::mount))]
Mount(PathBuf, io::Error), Mount(PathBuf, io::Error),
#[error("Failed to create symlink {0} in chroot: {1}")] #[error("Failed to create symlink to {0} in chroot: {1}")]
#[diagnostic(code(trm::chroot::symlink))] #[diagnostic(code(trm::chroot::symlink))]
Link(PathBuf, io::Error), Link(PathBuf, io::Error),

@ -11,7 +11,7 @@ mod args;
async fn main() -> miette::Result<()> { async fn main() -> miette::Result<()> {
miette::set_panic_hook(); miette::set_panic_hook();
color_eyre::install().unwrap(); color_eyre::install().unwrap();
dotenv::dotenv().unwrap(); let _ = dotenv::dotenv();
let args = Args::parse(); let args = Args::parse();
match args.command { match args.command {

@ -142,9 +142,9 @@ impl Mapping {
} }
fs::symlink(src, dst) fs::symlink(src, dst)
.await .await
.map_err(|e| ChrootError::Link(dst.to_owned(), e))?; .map_err(|e| ChrootError::Link(src.to_owned(), e))?;
Ok(MappingHandle::Link(LinkDrop { Ok(MappingHandle::Link(LinkDrop {
path: dst.to_owned(), path: src.to_owned(),
})) }))
} }
@ -152,12 +152,12 @@ impl Mapping {
if dst.exists() && dst.is_file() { if dst.exists() && dst.is_file() {
fs::remove_file(dst) fs::remove_file(dst)
.await .await
.map_err(|e| ChrootError::Copy(dst.to_owned(), e))?; .map_err(|e| ChrootError::Copy(src.to_owned(), e))?;
} }
fs::copy(src, dst) fs::copy(src, dst)
.await .await
.map_err(|e| ChrootError::Copy(dst.to_owned(), e))?; .map_err(|e| ChrootError::Copy(src.to_owned(), e))?;
Ok(MappingHandle::None) Ok(MappingHandle::None)
} }

Loading…
Cancel
Save