From d385cd16b02e3bdc9617d34ece9da1781f0a19c7 Mon Sep 17 00:00:00 2001 From: Tom McPhail Date: Mon, 9 Oct 2023 21:22:27 +1000 Subject: [PATCH] Additional file creation loop logic --- logfile.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/logfile.go b/logfile.go index 0228bed..3dd48f2 100644 --- a/logfile.go +++ b/logfile.go @@ -105,13 +105,18 @@ func (lf *logFile) dataProcessor(ctx context.Context, ewCancelChan <-chan error, case <-ctx.Done(): return case so := <-lf.stateEvents: - if so == stateEventCreated { + switch so { + case stateEventCreated: lf.created = true break + case stateEventRemoved: + lf.created = false + continue creationLoop + default: + stopChan <- lf.filePath + lf.errorChan <- NewLogWhaleError(ErrorStateInternal, fmt.Sprintf("unexpected state event while waiting for file creation: %s", so), nil) + return } - stopChan <- lf.filePath - lf.errorChan <- NewLogWhaleError(ErrorStateInternal, fmt.Sprintf("unexpected state event while waiting for file creation: %s", so), nil) - return } }