From 486a9afd8e086ff5311278476c7886abe8898fa3 Mon Sep 17 00:00:00 2001 From: Yoo1tic <137816438+Yoo1tic@users.noreply.github.com> Date: Thu, 17 Jul 2025 20:45:05 +0800 Subject: [PATCH] feat: format key output in write_keys_txt_file and ensure buffer flush in validation service --- src/adapters/output/local.rs | 2 +- src/validation.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/adapters/output/local.rs b/src/adapters/output/local.rs index e0ad252..017469b 100644 --- a/src/adapters/output/local.rs +++ b/src/adapters/output/local.rs @@ -9,7 +9,7 @@ pub async fn write_keys_txt_file( file: &mut BufWriter, key: &ApiKey, ) -> Result<()> { - file.write_all(key.as_str().as_bytes()).await?; + file.write_all(format!("{}\n", key.as_str()).as_bytes()).await?; Ok(()) } diff --git a/src/validation.rs b/src/validation.rs index 9fe6ced..8a12473 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -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(()) }