Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't os.File.Sync() on mac CAS items #143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cache/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"sort"
"sync"

"github.com/buchgr/bazel-remote/cache"
"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 {
Expand Down Expand Up @@ -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 {
Expand Down