Skip to content

Commit 68a311a

Browse files
committed
fix: refine codes
1 parent ca92a0d commit 68a311a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

core/src/ten_manager/src/fs/file_watcher.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ async fn watch_file_task(
184184
loop {
185185
// Wait for stop or the next check interval.
186186
tokio::select! {
187-
_ = &mut stop_rx => break,
187+
_ = &mut stop_rx => {
188+
eprintln!("Stopping file watcher");
189+
break;
190+
},
188191
_ = tokio::time::sleep(options.check_interval) => {
189192
// Check if the file has been rotated or truncated.
190193
match std::fs::metadata(&path) {
@@ -217,6 +220,7 @@ async fn watch_file_task(
217220
if curr_len > last_pos {
218221
// Read the new part.
219222
if let Err(e) = file.seek(SeekFrom::Start(last_pos)) {
223+
eprintln!("Error seeking to position: {}", e);
220224
let _ = content_tx.send(Err(anyhow::anyhow!(e))).await;
221225
break;
222226
}
@@ -231,13 +235,15 @@ async fn watch_file_task(
231235
}
232236
Ok(_) => {}
233237
Err(e) => {
238+
eprintln!("Error reading from file: {}", e);
234239
let _ = content_tx.send(Err(anyhow::anyhow!(e))).await;
235240
break;
236241
}
237242
}
238243
} else {
239244
// Reached EOF, check if the timeout has been reached.
240245
if Instant::now().duration_since(last_activity) > options.timeout {
246+
eprintln!("Timeout reached, breaking");
241247
break;
242248
}
243249
}

core/src/ten_manager/tests/test_case/fs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ mod tests {
6060
}
6161

6262
// Stop watching.
63+
println!("Stopping stream");
6364
stream.stop();
6465

6566
Ok(())

0 commit comments

Comments
 (0)