Skip to content

Commit

Permalink
💥 unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Oct 14, 2024
1 parent 4e01625 commit 71f9bd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
12 changes: 6 additions & 6 deletions cli/src/command/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn collect_items<I: IntoIterator<Item = P>, P: Into<PathBuf>>(
}
};
for path in walker.into_iter().flatten() {
let path = path?.into_path();
let path = path.unwrap().into_path();
if keep_dir || path.is_file() {
target_items.push(path);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ pub(crate) fn apply_metadata(
owner_options: OwnerOptions,
) -> io::Result<EntryBuilder> {
if keep_options.keep_timestamp || keep_options.keep_permission {
let meta = fs::metadata(path)?;
let meta = fs::metadata(path).unwrap();
if keep_options.keep_timestamp {
if let Ok(c) = meta.created() {
if let Ok(created_since_unix_epoch) = c.duration_since(UNIX_EPOCH) {
Expand All @@ -209,8 +209,8 @@ pub(crate) fn apply_metadata(
let mode = meta.permissions().mode() as u16;
let uid = owner_options.uid.unwrap_or(meta.uid());
let gid = owner_options.gid.unwrap_or(meta.gid());
let user = User::from_uid(uid.into())?;
let group = Group::from_gid(gid.into())?;
let user = User::from_uid(uid.into()).unwrap();
let group = Group::from_gid(gid.into()).unwrap();
entry.permission(pna::Permission::new(
uid.into(),
owner_options.uname.unwrap_or(user.name().into()),
Expand Down Expand Up @@ -248,7 +248,7 @@ pub(crate) fn apply_metadata(
if keep_options.keep_acl {
use crate::chunk;
use pna::RawChunk;
let ace_list = utils::acl::get_facl(path)?;
let ace_list = utils::acl::get_facl(path).unwrap();
for ace in ace_list {
entry.add_extra_chunk(RawChunk::from_data(chunk::faCe, ace.to_bytes()));
}
Expand All @@ -269,7 +269,7 @@ pub(crate) fn apply_metadata(
}
#[cfg(unix)]
if keep_options.keep_xattr {
for attr in utils::os::unix::fs::xattrs::get_xattrs(path)? {
for attr in utils::os::unix::fs::xattrs::get_xattrs(path).unwrap() {
entry.add_xattr(attr);
}
}
Expand Down
18 changes: 10 additions & 8 deletions cli/src/command/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ fn create_archive(args: CreateCommand) -> anyhow::Result<()> {
args.gitignore,
args.follow_links,
exclude,
)?;
)
.unwrap();

if let Some(parent) = archive.parent() {
fs::create_dir_all(parent)?;
fs::create_dir_all(parent).unwrap();
}
let max_file_size = args
.split
Expand Down Expand Up @@ -187,7 +188,8 @@ fn create_archive(args: CreateCommand) -> anyhow::Result<()> {
owner_options,
args.solid,
target_items,
)?;
)
.unwrap();
}
log::info!(
"Successfully created an archive in {}",
Expand All @@ -208,7 +210,7 @@ where
W: Write,
F: FnMut() -> io::Result<W>,
{
let pool = ThreadPoolBuilder::default().build()?;
let pool = ThreadPoolBuilder::default().build().unwrap();

let (tx, rx) = std::sync::mpsc::channel();
let option = if solid {
Expand All @@ -234,17 +236,17 @@ where

drop(tx);

let file = get_writer()?;
let file = get_writer().unwrap();
if solid {
let mut writer = Archive::write_solid_header(file, write_option)?;
let mut writer = Archive::write_solid_header(file, write_option).unwrap();
for entry in rx.into_iter() {
writer.add_entry(entry?)?;
writer.add_entry(entry.unwrap())?;
}
writer.finalize()?;
} else {
let mut writer = Archive::write_header(file)?;
for entry in rx.into_iter() {
writer.add_entry(entry?)?;
writer.add_entry(entry.unwrap())?;
}
writer.finalize()?;
}
Expand Down

0 comments on commit 71f9bd6

Please sign in to comment.