Skip to content
Snippets Groups Projects
Commit f9018830 authored by Anthony Woods's avatar Anthony Woods
Browse files

handle file renames

When a file is renamed a "rename" and a "create" event are sent.
We need to treat the rename as a remove.  If the new filename matches
the path glob, then we will start tailing it when the "create" event
is reveived.
parent dbaf46a3
No related branches found
No related tags found
No related merge requests found
......@@ -157,6 +157,14 @@ func (t *Target) run() {
tailer.cleanup()
delete(t.tails, event.Name)
}
case fsnotify.Rename:
// Rename is only issued on the original file path; the new name receives a Create event
tailer, ok := t.tails[event.Name]
if ok {
helpers.LogError("stopping tailer", tailer.stop)
tailer.cleanup()
delete(t.tails, event.Name)
}
default:
level.Debug(t.logger).Log("msg", "got unknown event", "event", event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment