Skip to content

Commit 494a6cf

Browse files
committed
Stop File tailing on truncate & Small improvement.
* Stop file tailing if file get truncated returning and IO error because session should be terminated at this point. * Avoid allocating string for logging channels errors since the channel will return the sent item on errors.
1 parent 207dff9 commit 494a6cf

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

application/apps/indexer/session/src/operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ impl OperationAPI {
202202
}
203203

204204
pub fn emit(&self, event: stypes::CallbackEvent) {
205-
let event_log = format!("{event:?}");
206205
if let Err(err) = self.tx_callback_events.send(event) {
206+
let event_log = format!("{:?}", err.0);
207207
error!("Fail to send event {event_log}; error: {err}")
208208
}
209209
}

application/apps/indexer/session/src/tail/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ pub async fn track(
4141
.map(|md| md.len())
4242
.map_err(|e| Error::Io(e.to_string()))?;
4343
if updated != size {
44+
let truncated = size > updated;
45+
if truncated {
46+
log::info!("File has been truncated. Path: {}", path.display());
47+
return Err(Error::Io(String::from("File has been truncated")));
48+
}
4449
size = updated;
4550
if let Err(err) = tx_update.send(Ok(())).await {
4651
return Err(Error::Channel(format!("Fail to send update signal: {err}")));

application/holder/src/env/fs/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,3 @@ export async function getFileTypeByFilename(filename: string): Promise<FileType>
148148
return FileType.Text;
149149
}
150150
}
151-

0 commit comments

Comments
 (0)