Skip to content

Commit

Permalink
[chore][pkg/stanza] Flatten handling of lost files (#27454)
Browse files Browse the repository at this point in the history
Subset of #27434
  • Loading branch information
djaglowski authored Oct 6, 2023
1 parent ce7593e commit 4796666
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pkg/stanza/fileconsumer/roller_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ OUTER:
if newReader.Fingerprint.StartsWith(oldReader.Fingerprint) {
continue OUTER
}
if oldReader.FileName == newReader.FileName {
// At this point, we know that the file has been rotated. However, we do not know
// if it was moved or truncated. If truncated, then both handles point to the same
// file, in which case we should only read from it using the new reader. We can use
// the ValidateOrClose method to establish that the file has not been truncated.
if !oldReader.ValidateOrClose() {
continue OUTER
}

if oldReader.FileName != newReader.FileName {
continue
}

// At this point, we know that the file has been rotated. However, we do not know
// if it was moved or truncated. If truncated, then both handles point to the same
// file, in which case we should only read from it using the new reader. We can use
// the ValidateOrClose method to establish that the file has not been truncated.
if !oldReader.ValidateOrClose() {
continue OUTER
}
}
lostReaders = append(lostReaders, oldReader)
Expand Down

0 comments on commit 4796666

Please sign in to comment.