feat: format key output in write_keys_txt_file and ensure buffer flush in validation service

main
Yoo1tic 2025-07-17 20:45:05 +08:00
parent 96ac85072e
commit 486a9afd8e
2 changed files with 5 additions and 2 deletions

View File

@ -9,7 +9,7 @@ pub async fn write_keys_txt_file(
file: &mut BufWriter<tokio::fs::File>,
key: &ApiKey,
) -> Result<()> {
file.write_all(key.as_str().as_bytes()).await?;
file.write_all(format!("{}\n", key.as_str()).as_bytes()).await?;
Ok(())
}

View File

@ -3,7 +3,7 @@ use async_stream::stream;
use futures::{pin_mut, stream::StreamExt};
use reqwest::Client;
use std::time::Instant;
use tokio::{fs, sync::mpsc};
use tokio::{fs, io::AsyncWriteExt, sync::mpsc};
use crate::adapters::write_keys_txt_file;
use crate::config::KeyCheckerConfig;
@ -59,6 +59,9 @@ impl ValidationService {
}
}
// Flush the buffer to ensure all data is written to the file
buffer_writer.flush().await?;
println!("Total Elapsed Time: {:?}", start_time.elapsed());
Ok(())
}