Run clippy on the whole project (v2) #73
5 changed files with 38 additions and 38 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -137,7 +137,7 @@ impl BlockManager {
|
|||
Message::PutBlock(m) => self.write_block(&m.hash, &m.data).await,
|
||||
Message::GetBlock(h) => self.read_block(h).await,
|
||||
Message::NeedBlockQuery(h) => self.need_block(h).await.map(Message::NeedBlockReply),
|
||||
_ => Err(Error::BadRPC(format!("Unexpected RPC message"))),
|
||||
_ => Err(Error::BadRPC("Unexpected RPC message".to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,8 +280,8 @@ impl BlockManager {
|
|||
if let Err(e) = self.resync_iter(&mut must_exit).await {
|
||||
warn!("Error in block resync loop: {}", e);
|
||||
select! {
|
||||
_ = tokio::time::sleep(Duration::from_secs(1)).fuse() => (),
|
||||
_ = must_exit.changed().fuse() => (),
|
||||
_ = tokio::time::sleep(Duration::from_secs(1)).fuse() => {},
|
||||
_ = must_exit.changed().fuse() => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,15 +304,15 @@ impl BlockManager {
|
|||
} else {
|
||||
let delay = tokio::time::sleep(Duration::from_millis(time_msec - now));
|
||||
select! {
|
||||
_ = delay.fuse() => (),
|
||||
_ = self.resync_notify.notified().fuse() => (),
|
||||
_ = must_exit.changed().fuse() => (),
|
||||
_ = delay.fuse() => {},
|
||||
_ = self.resync_notify.notified().fuse() => {},
|
||||
_ = must_exit.changed().fuse() => {},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
select! {
|
||||
_ = self.resync_notify.notified().fuse() => (),
|
||||
_ = must_exit.changed().fuse() => (),
|
||||
_ = self.resync_notify.notified().fuse() => {},
|
||||
_ = must_exit.changed().fuse() => {},
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -342,7 +342,7 @@ impl BlockManager {
|
|||
|
||||
let mut who = self.replication.write_nodes(&hash);
|
||||
if who.len() < self.replication.write_quorum() {
|
||||
return Err(Error::Message(format!("Not trying to offload block because we don't have a quorum of nodes to write to")));
|
||||
return Err(Error::Message("Not trying to offload block because we don't have a quorum of nodes to write to".to_string()));
|
||||
}
|
||||
who.retain(|id| *id != self.system.id);
|
||||
|
||||
|
@ -362,14 +362,14 @@ impl BlockManager {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::Message(format!(
|
||||
"Unexpected response to NeedBlockQuery RPC"
|
||||
)));
|
||||
return Err(Error::Message(
|
||||
"Unexpected response to NeedBlockQuery RPC".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if need_nodes.len() > 0 {
|
||||
if !need_nodes.is_empty() {
|
||||
trace!(
|
||||
"Block {:?} needed by {} nodes, sending",
|
||||
hash,
|
||||
|
@ -478,7 +478,7 @@ impl BlockManager {
|
|||
|
||||
fn repair_aux_read_dir_rec<'a>(
|
||||
&'a self,
|
||||
path: &'a PathBuf,
|
||||
path: &'a Path,
|
||||
must_exit: &'a watch::Receiver<bool>,
|
||||
) -> BoxFuture<'a, Result<(), Error>> {
|
||||
// Lists all blocks on disk and adds them to the resync queue.
|
||||
|
|
|
@ -50,7 +50,7 @@ impl TableSchema for BlockRefTable {
|
|||
type Filter = DeletedFilter;
|
||||
|
||||
fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) {
|
||||
let block = &old.as_ref().or(new.as_ref()).unwrap().block;
|
||||
let block = &old.as_ref().or_else(|| new.as_ref()).unwrap().block;
|
||||
let was_before = old.as_ref().map(|x| !x.deleted.get()).unwrap_or(false);
|
||||
let is_after = new.as_ref().map(|x| !x.deleted.get()).unwrap_or(false);
|
||||
if is_after && !was_before {
|
||||
|
|
|
@ -49,13 +49,6 @@ pub struct BucketParams {
|
|||
pub website: crdt::LWW<bool>,
|
||||
}
|
||||
|
||||
impl CRDT for BucketParams {
|
||||
fn merge(&mut self, o: &Self) {
|
||||
self.authorized_keys.merge(&o.authorized_keys);
|
||||
self.website.merge(&o.website);
|
||||
}
|
||||
}
|
||||
|
||||
impl BucketParams {
|
||||
/// Create an empty BucketParams with no authorized keys and no website accesss
|
||||
pub fn new() -> Self {
|
||||
|
@ -66,6 +59,19 @@ impl BucketParams {
|
|||
}
|
||||
}
|
||||
|
||||
impl CRDT for BucketParams {
|
||||
fn merge(&mut self, o: &Self) {
|
||||
self.authorized_keys.merge(&o.authorized_keys);
|
||||
self.website.merge(&o.website);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BucketParams {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Bucket {
|
||||
/// Initializes a new instance of the Bucket struct
|
||||
pub fn new(name: String) -> Self {
|
||||
|
|
|
@ -95,7 +95,7 @@ impl Garage {
|
|||
BlockRefTable {
|
||||
block_manager: block_manager.clone(),
|
||||
},
|
||||
data_rep_param.clone(),
|
||||
data_rep_param,
|
||||
system.clone(),
|
||||
&db,
|
||||
"block_ref".to_string(),
|
||||
|
@ -121,7 +121,7 @@ impl Garage {
|
|||
background: background.clone(),
|
||||
version_table: version_table.clone(),
|
||||
},
|
||||
meta_rep_param.clone(),
|
||||
meta_rep_param,
|
||||
system.clone(),
|
||||
&db,
|
||||
"object".to_string(),
|
||||
|
@ -141,7 +141,7 @@ impl Garage {
|
|||
info!("Initialize key_table_table...");
|
||||
let key_table = Table::new(
|
||||
KeyTable,
|
||||
control_rep_param.clone(),
|
||||
control_rep_param,
|
||||
system.clone(),
|
||||
&db,
|
||||
"key".to_string(),
|
||||
|
@ -152,9 +152,9 @@ impl Garage {
|
|||
let garage = Arc::new(Self {
|
||||
config,
|
||||
db,
|
||||
system: system.clone(),
|
||||
block_manager,
|
||||
background,
|
||||
system,
|
||||
block_manager,
|
||||
bucket_table,
|
||||
key_table,
|
||||
object_table,
|
||||
|
|
|
@ -40,6 +40,7 @@ impl Object {
|
|||
}
|
||||
|
||||
/// Adds a version if it wasn't already present
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub fn add_version(&mut self, new: ObjectVersion) -> Result<(), ()> {
|
||||
match self
|
||||
.versions
|
||||
|
@ -145,18 +146,12 @@ impl ObjectVersion {
|
|||
|
||||
/// Is the object version currently being uploaded
|
||||
pub fn is_uploading(&self) -> bool {
|
||||
match self.state {
|
||||
ObjectVersionState::Uploading(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.state, ObjectVersionState::Uploading(_))
|
||||
}
|
||||
|
||||
/// Is the object version completely received
|
||||
pub fn is_complete(&self) -> bool {
|
||||
match self.state {
|
||||
ObjectVersionState::Complete(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.state, ObjectVersionState::Complete(_))
|
||||
}
|
||||
|
||||
/// Is the object version available (received and not a tombstone)
|
||||
|
@ -207,8 +202,7 @@ impl CRDT for Object {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.rev()
|
||||
.filter(|(_, v)| v.is_complete())
|
||||
.next()
|
||||
.find(|(_, v)| v.is_complete())
|
||||
.map(|(vi, _)| vi);
|
||||
|
||||
if let Some(last_vi) = last_complete {
|
||||
|
|
Loading…
Reference in a new issue