Small tweak in message passing
This commit is contained in:
parent
3d0151610d
commit
0a94691685
@ -5,7 +5,7 @@ use {
|
|||||||
borrow::BorrowMut,
|
borrow::BorrowMut,
|
||||||
env,
|
env,
|
||||||
error::Error,
|
error::Error,
|
||||||
fs::{File, self},
|
fs::{self, File},
|
||||||
io::{self, Write},
|
io::{self, Write},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{
|
sync::{
|
||||||
@ -97,10 +97,7 @@ impl Creator {
|
|||||||
plist.lock().unwrap().borrow_mut().entries.push(item.entry);
|
plist.lock().unwrap().borrow_mut().entries.push(item.entry);
|
||||||
match writer.lock().unwrap().borrow_mut().write_all(&item.data) {
|
match writer.lock().unwrap().borrow_mut().write_all(&item.data) {
|
||||||
Ok(_) => sender
|
Ok(_) => sender
|
||||||
.send(Message::MemberAdded(format!(
|
.send(Message::MemberAdded(format!("{}", path.display())))
|
||||||
"{} added to archive",
|
|
||||||
path.display()
|
|
||||||
)))
|
|
||||||
.expect("couldn't send message"),
|
.expect("couldn't send message"),
|
||||||
Err(e) => sender
|
Err(e) => sender
|
||||||
.send(Message::Failure(format!("{e}")))
|
.send(Message::Failure(format!("{e}")))
|
||||||
|
@ -5,8 +5,10 @@ use std::{
|
|||||||
ffi::CStr,
|
ffi::CStr,
|
||||||
fmt::{self, Write},
|
fmt::{self, Write},
|
||||||
fs::{self, Metadata},
|
fs::{self, Metadata},
|
||||||
|
io,
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
os::{linux::fs::MetadataExt, unix::fs::FileTypeExt}, path::PathBuf, io,
|
os::{linux::fs::MetadataExt, unix::fs::FileTypeExt},
|
||||||
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
@ -225,11 +227,21 @@ impl Header {
|
|||||||
let path = PathBuf::from(&filename);
|
let path = PathBuf::from(&filename);
|
||||||
let name = match path.file_name().and_then(|n| n.to_str()) {
|
let name = match path.file_name().and_then(|n| n.to_str()) {
|
||||||
Some(n) => n.to_string(),
|
Some(n) => n.to_string(),
|
||||||
None => return Err(Error::Io(io::Error::new(io::ErrorKind::Other, "Cannot get file name"))),
|
None => {
|
||||||
|
return Err(Error::Io(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
"Cannot get file name",
|
||||||
|
)))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let dir = match path.parent() {
|
let dir = match path.parent() {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return Err(Error::Io(io::Error::new(io::ErrorKind::Other, "Cannot get path prefix"))),
|
None => {
|
||||||
|
return Err(Error::Io(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
"Cannot get path prefix",
|
||||||
|
)))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
(name, Some(format!("{}", dir.display())))
|
(name, Some(format!("{}", dir.display())))
|
||||||
};
|
};
|
||||||
@ -288,11 +300,21 @@ impl Header {
|
|||||||
let path = PathBuf::from(&filename);
|
let path = PathBuf::from(&filename);
|
||||||
let name = match path.file_name().and_then(|n| n.to_str()) {
|
let name = match path.file_name().and_then(|n| n.to_str()) {
|
||||||
Some(n) => n.to_string(),
|
Some(n) => n.to_string(),
|
||||||
None => return Err(Error::Io(io::Error::new(io::ErrorKind::Other, "Cannot get file name"))),
|
None => {
|
||||||
|
return Err(Error::Io(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
"Cannot get file name",
|
||||||
|
)))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let dir = match path.parent() {
|
let dir = match path.parent() {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return Err(Error::Io(io::Error::new(io::ErrorKind::Other, "Cannot get path prefix"))),
|
None => {
|
||||||
|
return Err(Error::Io(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
"Cannot get path prefix",
|
||||||
|
)))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
(name, Some(format!("{}", dir.display())))
|
(name, Some(format!("{}", dir.display())))
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user