From bdb2c5b68d514d47aa526d2b1e89b3e6dc18c2ce Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Wed, 30 Aug 2023 16:06:07 -0400 Subject: [PATCH] fixup: hack for re-reads Signed-off-by: Todd Baert --- grpc-sync-server/pkg/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grpc-sync-server/pkg/server.go b/grpc-sync-server/pkg/server.go index 71896c7..0c45f98 100644 --- a/grpc-sync-server/pkg/server.go +++ b/grpc-sync-server/pkg/server.go @@ -8,6 +8,7 @@ import ( "log" "net" "os" + "time" "github.com/fsnotify/fsnotify" "golang.org/x/exp/maps" @@ -126,6 +127,13 @@ func (s *SyncImpl) readFlags() ([]byte, error) { for _, path := range s.filePaths { bytes, err := os.ReadFile(path) + if len(bytes) == 0 { + // this is a fitly hack + // file writes are NOT atomic and often when they are changed they have transitional empty states + // this "re-reads" the file in these cases 10ms later + time.Sleep(10 * time.Millisecond) + bytes, err = os.ReadFile(path) + } if err != nil { return nil, err }