Skip to content

Commit

Permalink
Fixed lints.
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kirilin <win10@list.ru>
  • Loading branch information
s3rius committed Dec 11, 2023
1 parent 8b9571f commit 9ef4d69
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/data_storage/impls/file_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Storage for FileStorage {
.open(path.as_str())
.await?;
let mut writer = tokio::io::BufWriter::new(file);
writer.write_all(&mut bytes).await?;
writer.write_all(&bytes).await?;
writer.flush().await?;
if self.force_fsync {
writer.get_ref().sync_data().await?;
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Storage for FileStorage {
.await?;
let mut reader = tokio::io::BufReader::new(part_file);
tokio::io::copy_buf(&mut reader, &mut writer).await?;
reader.shutdown().await?
reader.shutdown().await?;
}
writer.flush().await?;
if self.force_fsync {
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn greeting(app_conf: &config::Config) {
fn main() -> RustusResult<()> {
let args = config::Config::parse();
greeting(&args);
#[allow(clippy::no_effect_underscore_binding)]
let mut _guard = None;
if let Some(sentry_dsn) = &args.sentry_config.dsn {
let default_options = sentry::ClientOptions::default();
Expand All @@ -66,7 +67,7 @@ fn main() -> RustusResult<()> {
.sentry_config
.environment
.clone()
.map(|val| Cow::from(val))
.map(Cow::from)
.clone(),
release: sentry::release_name!(),
debug: args.sentry_config.debug,
Expand Down
2 changes: 1 addition & 1 deletion src/notifiers/impls/file_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Notifier for FileNotifier {
.spawn()?;
let stat = command.wait().await?;
if !stat.success() {
tracing::Span::current().record("exit_status", &stat.code().unwrap_or(0));
tracing::Span::current().record("exit_status", stat.code().unwrap_or(0));
return Err(RustusError::HookError("Returned wrong status code".into()));
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub async fn start(config: Config) -> RustusResult<()> {
})
.on_response(
|response: &Response, latency: Duration, span: &tracing::Span| {
span.record("status", &response.status().as_u16());
span.record("status", response.status().as_u16());
span.record("duration", latency.as_millis());
tracing::info!("response");
},
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn handler(
Path(upload_id): Path<String>,
body: Bytes,
) -> RustusResult<axum::response::Response> {
tracing::Span::current().record("upload_id", &upload_id.as_str());
tracing::Span::current().record("upload_id", upload_id.as_str());
if !headers.check("Content-Type", |val| {
val == "application/offset+octet-stream"
}) {
Expand Down
9 changes: 6 additions & 3 deletions src/utils/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ pub trait MonadLogger: Sized {
#[must_use]
fn _should_log(&self) -> bool;

#[must_use]
fn mlog_err(self, msg: &str) -> Self {
if self._should_log() {
tracing::error!(msg)
tracing::error!(msg);
}
self
}

#[must_use]
fn mlog_warn(self, msg: &str) -> Self {
if self._should_log() {
tracing::warn!(msg)
tracing::warn!(msg);
}
self
}

#[must_use]
#[allow(unused_variables)]
fn mlog_dbg(self, msg: &str) -> Self {
#[cfg(debug_assertions)]
if self._should_log() {
tracing::debug!(msg)
tracing::debug!(msg);
}
self
}
Expand Down

0 comments on commit 9ef4d69

Please sign in to comment.