fix: clippy cleanups in upload tracking and share plumbing
This commit is contained in:
@@ -46,7 +46,7 @@ impl Client {
|
||||
let shared_folder_count = shares.folder_count();
|
||||
let shared_file_count = shares.file_count();
|
||||
ctx.shares = shares;
|
||||
ctx.shared_directories = self.shared_directories.clone();
|
||||
ctx.shared_directories.clone_from(&self.shared_directories);
|
||||
|
||||
let server_actor = ServerActor::new(
|
||||
self.address.clone(),
|
||||
|
||||
@@ -701,6 +701,7 @@ impl Client {
|
||||
|
||||
/// Ask an in-progress upload to `username` of `filename` to stop.
|
||||
/// Returns whether a matching in-progress upload was found.
|
||||
#[must_use = "returns whether a matching upload was found"]
|
||||
pub fn cancel_upload(&self, username: &str, filename: &str) -> bool {
|
||||
self.context.read_safe().is_ok_and(|ctx| {
|
||||
let mut found = false;
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn serve_file(
|
||||
let mut offset = [0u8; 8];
|
||||
stream.read_exact(&mut offset)?;
|
||||
|
||||
let mut buffer = [0u8; 64 * 1024];
|
||||
let mut buffer = vec![0u8; 64 * 1024];
|
||||
loop {
|
||||
if cancel.load(Ordering::Relaxed) {
|
||||
return Err(io::Error::new(
|
||||
@@ -154,7 +154,7 @@ mod tests {
|
||||
// Cancelled before the copy loop starts: the stream must abort with
|
||||
// Interrupted instead of serving the whole file.
|
||||
let cancel = Arc::new(AtomicBool::new(true));
|
||||
let cancel_flag = cancel.clone();
|
||||
let cancel_flag = cancel;
|
||||
let uploader = std::thread::spawn(move || {
|
||||
serve_file(
|
||||
"127.0.0.1",
|
||||
|
||||
@@ -307,7 +307,7 @@ mod tests {
|
||||
std::fs::write(music_a.join("a.mp3"), b"a").unwrap();
|
||||
std::fs::write(music_b.join("b.mp3"), b"b").unwrap();
|
||||
|
||||
let shares = Shares::scan_many(&[music_a.clone(), music_b.clone()]);
|
||||
let shares = Shares::scan_many(&[music_a, music_b]);
|
||||
assert!(shares.get("music\\a.mp3").is_some());
|
||||
assert!(
|
||||
shares.get("music (2)\\b.mp3").is_some(),
|
||||
|
||||
Reference in New Issue
Block a user