Skip to content

Commit

Permalink
Fix the wrong event type for a new file (#36098) (#36102)
Browse files Browse the repository at this point in the history
It's supposed to emit a `create` event, not a `write` event when a
previously ignored empty file gets written to.

(cherry picked from commit f52d38a)

Co-authored-by: Denis <denis.rechkunov@elastic.co>
  • Loading branch information
mergify[bot] and rdner authored Jul 18, 2023
1 parent 195e58e commit ec49a82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions filebeat/input/filestream/fswatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (w *fileWatcher) watch(ctx unison.Canceler) {
// no need to react on empty new files
if fd.Info.Size() == 0 {
w.log.Warnf("file %q has no content yet, skipping", fd.Filename)
delete(paths, path)
continue
}
select {
Expand Down
3 changes: 1 addition & 2 deletions filebeat/input/filestream/fswatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ scanner:
e := fw.Event()
expEvent := loginp.FSEvent{
NewPath: filename,
OldPath: filename,
Op: loginp.OpWrite,
Op: loginp.OpCreate,
Descriptor: loginp.FileDescriptor{
Filename: filename,
Info: testFileInfo{path: basename, size: 5}, // +5 bytes appended
Expand Down

0 comments on commit ec49a82

Please sign in to comment.