From d3734a47cdf9f0a39c11674fce97c4b102548157 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Sat, 16 Jan 2016 20:09:24 -0800 Subject: [PATCH] stating an existing file only once --- client/driver/logs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/driver/logs.go b/client/driver/logs.go index 0e6758a29..7673637a2 100644 --- a/client/driver/logs.go +++ b/client/driver/logs.go @@ -65,21 +65,19 @@ func (l *LogRotator) Start(r io.Reader) error { buf := make([]byte, bufSize) for { logFileName := filepath.Join(l.path, fmt.Sprintf("%s.%d", l.fileName, l.logFileIdx)) + remainingSize := l.fileSize if f, err := os.Stat(logFileName); err == nil { if f.IsDir() { l.logFileIdx += 1 continue } + remainingSize = l.fileSize - f.Size() } f, err := os.OpenFile(logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { return err } l.logger.Println("[INFO] logrotator: opened a new file: %s", logFileName) - remainingSize := l.fileSize - if finfo, err := os.Stat(logFileName); err == nil { - remainingSize -= finfo.Size() - } if remainingSize < 1 { l.logFileIdx = l.logFileIdx + 1 f.Close()