Skip to content

Commit

Permalink
fix entry duplication at beginning of file(s) (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Sirianni authored Mar 8, 2022
1 parent 5198c73 commit 33707f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion operator/builtin/input/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ OUTER:
// Empty file, don't read it until we can compare its fingerprint
fps = append(fps[:i], fps[i+1:]...)
files = append(files[:i], files[i+1:]...)

i--
continue
}

for j := i + 1; j < len(fps); j++ {
Expand All @@ -244,6 +245,7 @@ OUTER:
// Exclude
fps = append(fps[:i], fps[i+1:]...)
files = append(files[:i], files[i+1:]...)
i--
continue OUTER
}
}
Expand Down
23 changes: 23 additions & 0 deletions operator/builtin/input/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,29 @@ func TestSplitWrite(t *testing.T) {
waitForMessage(t, logReceived, "testlog1testlog2")
}

func TestIgnoreEmptyFiles(t *testing.T) {
t.Parallel()
operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
defer operator.Stop()

temp := openTemp(t, tempDir)
temp2 := openTemp(t, tempDir)
temp3 := openTemp(t, tempDir)
temp4 := openTemp(t, tempDir)

writeString(t, temp, "testlog1\n")
writeString(t, temp3, "testlog2\n")
operator.poll(context.Background())

waitForMessages(t, logReceived, []string{"testlog1", "testlog2"})

writeString(t, temp2, "testlog3\n")
writeString(t, temp4, "testlog4\n")
operator.poll(context.Background())

waitForMessages(t, logReceived, []string{"testlog3", "testlog4"})
}

func TestDecodeBufferIsResized(t *testing.T) {
t.Parallel()
operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
Expand Down

0 comments on commit 33707f8

Please sign in to comment.