🐛 fix(actions): use nightly for rustfmt

Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
Pauline 2024-08-17 21:22:52 +02:00
parent c820a57fc5
commit 986bf51e2e
No known key found for this signature in database
GPG key ID: 722BB181973296AE
3 changed files with 4 additions and 23 deletions

View file

@ -101,7 +101,7 @@ jobs:
- name: Run Rustfmt
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
run: cargo fmt --all -- --check
run: cargo +nightly fmt --all -- --check
clippy:
strategy:

View file

@ -7,7 +7,6 @@ use crate::utils::io::{self, IOError};
use futures::TryFutureExt;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::io::Read;
use std::time::SystemTime;
use tokio::io::{AsyncReadExt, AsyncSeekExt};
@ -238,29 +237,12 @@ pub async fn delete_logs_by_file(
pub async fn read_log_to_string(path: &std::path::PathBuf) -> crate::Result<String> {
if let Some(ext) = path.extension() {
let mut file = std::fs::File::open(path).map_err(|e| IOError::with_path(e, path))?;
let mut contents = [0; 1024];
let mut result = String::new();
if ext == "gz" {
let mut gz = flate2::read::GzDecoder::new(std::io::BufReader::new(file));
while gz
.read(&mut contents)
.map_err(|e| IOError::with_path(e, path))?
> 0
{
result.push_str(&String::from_utf8_lossy(&contents));
contents = [0; 1024];
}
result = io::read_gz_to_string(path).await?;
} else if ext == "log" || ext == "txt" {
while file
.read(&mut contents)
.map_err(|e| IOError::with_path(e, path))?
> 0
{
result.push_str(&String::from_utf8_lossy(&contents));
contents = [0; 1024];
}
result = io::read_to_string(path).await?;
}
return Ok(result);

View file

@ -9,7 +9,6 @@ use std::time::Duration;
use bytes::Bytes;
use reqwest::Method;
use serde::de::DeserializeOwned;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use tokio::sync::{RwLock, Semaphore};
@ -244,7 +243,7 @@ pub async fn write<'a>(path: &Path, bytes: &[u8], semaphore: &IoSemaphore) -> cr
io::create_dir_all(parent).await?;
}
let mut file = File::create(path)
let mut file = tokio::fs::File::create(path)
.await
.map_err(|e| IOError::with_path(e, path))?;
file.write_all(bytes)