diff --git a/cache/disk/disk.go b/cache/disk/disk.go index 559a065fb..673d19969 100644 --- a/cache/disk/disk.go +++ b/cache/disk/disk.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "path/filepath" + "runtime" "sort" "sync" @@ -17,6 +18,8 @@ import ( "github.com/djherbis/atime" ) +const isMac = runtime.GOOS == "darwin" + // lruItem is the type of the values stored in SizedLRU to keep track of items. // It implements the SizedItem interface. type lruItem struct { @@ -236,8 +239,11 @@ func (c *diskCache) Put(kind cache.EntryKind, hash string, expectedSize int64, r } } - if err := f.Sync(); err != nil { - return err + shouldSync := !isMac || kind != cache.CAS + if shouldSync { + if err := f.Sync(); err != nil { + return err + } } if err := f.Close(); err != nil {