Skip to content

Commit e630f5c

Browse files
committed
fix linter
1 parent 3f598d9 commit e630f5c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

plugin/input/file/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func pluginConfig(opts ...string) *Config {
8787
PersistenceMode: "async",
8888
OffsetsOp: op,
8989
MaintenanceInterval: "5s",
90-
RemoveAfter: "5s",
90+
RemoveAfter: "0",
9191
}
9292
test.NewConfig(config, map[string]int{"gomaxprocs": runtime.GOMAXPROCS(0)})
9393

plugin/input/file/offset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (o *offsetDB) parseOptionalLine(content string, prefix string) (string, str
218218
return o.parseLine(content, prefix)
219219
}
220220

221-
if strings.HasPrefix(content, " streams:") || (len(content) > 0 && content[0] == '-') {
221+
if strings.HasPrefix(content, " streams:") || (content != "" && content[0] == '-') {
222222
return "", content, nil
223223
}
224224

plugin/input/file/worker.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (w *worker) work(controller inputer, jobProvider *jobProvider, readBufferSi
100100
var reader io.Reader
101101
if job.mimeType == "application/x-lz4" {
102102
if isNotFileBeingWritten(file.Name()) {
103-
// lz4 does not support appending, so we check that no one is writting to the file
103+
// lz4 does not support appending, so we check that no one is writing to the file
104104
logger.Error("cannot lock file", zap.String("filename", file.Name()))
105105
break
106106
}
@@ -283,9 +283,15 @@ func (w *worker) processEOF(file *os.File, job *Job, jobProvider *jobProvider, t
283283

284284
if w.removeAfter > 0 && time.Since(job.eofReadInfo.getTimestamp()) > w.removeAfter {
285285
job.mu.Lock()
286-
file.Close()
286+
err = file.Close()
287+
if err != nil {
288+
jobProvider.logger.Errorf("cannot close file %s: ", err)
289+
}
287290
jobProvider.deleteJobAndUnlock(job)
288-
os.Remove(file.Name())
291+
err = os.Remove(file.Name())
292+
if err != nil {
293+
jobProvider.logger.Errorf("cannot remove file %s: ", err)
294+
}
289295
}
290296

291297
return nil

0 commit comments

Comments
 (0)