From 2f28edba01f05c1e065739deb7bd3dabade7d2a6 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 7 Jun 2020 11:54:01 +0200 Subject: [PATCH] Fixed recompressing of stale files --- fs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs.go b/fs.go index a35189b..dd6234b 100644 --- a/fs.go +++ b/fs.go @@ -1141,7 +1141,10 @@ func (h *fsHandler) openFSFile(filePath string, mustCompress bool) (*fsFile, err return nil, fmt.Errorf("cannot obtain info for original file %q: %s", filePathOriginal, err) } - if fileInfoOriginal.ModTime() != fileInfo.ModTime() { + // Only re-create the compressed file if there was more than a second between the mod times. + // On MacOS the gzip seems to truncate the nanoseconds in the mod time causing the original file + // to look newer than the gzipped file. + if fileInfo.ModTime().Sub(fileInfoOriginal.ModTime()) >= time.Second { // The compressed file became stale. Re-create it. f.Close() os.Remove(filePath)