🐛 fix(actions): use nightly for rustfmt
Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
parent
c820a57fc5
commit
986bf51e2e
3 changed files with 4 additions and 23 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue