Skip to content

Commit

Permalink
ci: clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
de-sh committed Apr 5, 2024
1 parent d8e60cc commit 8ea0a10
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bytes::{Buf, BufMut, BytesMut};
use log::{self, debug, error, info, warn};
use log::{debug, error, info, warn};
use seahash::hash;

use std::collections::VecDeque;
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<'a> PersistenceFile<'a> {
/// Write contents of buffer from memory onto the persistence file in disk
pub fn write(&mut self, buf: &mut BytesMut) -> Result<(), Error> {
let path = self.path();
let mut file = OpenOptions::new().write(true).create(true).open(path)?;
let mut file = OpenOptions::new().write(true).create(true).truncate(true).open(path)?;

let hash = hash(&buf[..]);
file.write_all(&hash.to_be_bytes())?;
Expand Down
2 changes: 1 addition & 1 deletion uplink/src/base/bridge/actions_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl ActionsBridge {
action.name, fwd_name, action.action_id,
);

action.name = fwd_name.to_owned();
fwd_name.clone_into(&mut action.name);

if let Err(e) = self.try_route_action(action.clone()) {
error!("Failed to route action to app. Error = {:?}", e);
Expand Down
2 changes: 1 addition & 1 deletion uplink/src/base/serializer/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Metrics {
}

pub fn set_mode(&mut self, name: &str) {
self.mode = name.to_owned();
name.clone_into(&mut self.mode);
}

pub fn batches(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions uplink/src/collector/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl FileDownloader {

info!("Downloader thread is ready to receive download actions");
while let Ok(action) = self.actions_rx.recv_async().await {
self.action_id = action.action_id.clone();
action.action_id.clone_into(&mut self.action_id);
let mut state = match DownloadState::new(action, &self.config) {
Ok(s) => s,
Err(e) => {
Expand Down Expand Up @@ -186,7 +186,7 @@ impl FileDownloader {
return;
}
};
self.action_id = state.current.action.action_id.clone();
state.current.action.action_id.clone_into(&mut self.action_id);

if let Err(e) = self.download(&mut state).await {
self.forward_error(e).await;
Expand Down
2 changes: 1 addition & 1 deletion uplink/src/collector/preconditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl PreconditionChecker {
// comparison instead of making assumptions about what the user might want.
fn check_disk_size(&self, preconditions: Preconditions) -> Result<(), Error> {
let Some(mut required_free_space) = preconditions.uncompressed_length else {
return Ok(())
return Ok(());
};
let disk_free_space =
fs2::free_space(&self.config.precondition_checks.as_ref().unwrap().path)? as usize;
Expand Down
2 changes: 1 addition & 1 deletion uplink/src/collector/script_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl ScriptRunner {
continue;
},
};
status.action_id = id.to_owned();
id.clone_into(&mut status.action_id);

debug!("Action status: {:?}", status);
self.forward_status(status).await;
Expand Down
5 changes: 1 addition & 4 deletions uplink/src/collector/systemstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ pub struct System {
impl System {
fn init(sys: &sysinfo::System) -> System {
System {
kernel_version: match sys.kernel_version() {
Some(kv) => kv,
None => String::default(),
},
kernel_version: sys.kernel_version().unwrap_or_default(),
total_memory: sys.total_memory(),
..Default::default()
}
Expand Down

0 comments on commit 8ea0a10

Please sign in to comment.