Skip to content

Commit

Permalink
fix: race condition on sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Vidmar committed Oct 2, 2023
1 parent 524dd9d commit 9b9fdad
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion erm/templates/contentful_vo_lib.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ func (cc *ContentfulClient) UpdateCache(ctx context.Context, contentTypes []stri
ctxAtWork, cancel := context.WithTimeout(ctx, time.Second*time.Duration(cc.cacheUpdateTimeout))
defer cancel()
localOffline := cc.offline
isSync := cc.sync
cc.cacheMutex.sharedDataGcLock.RUnlock()

if localOffline {
Expand All @@ -632,7 +633,7 @@ func (cc *ContentfulClient) UpdateCache(ctx context.Context, contentTypes []stri
}
}
}
if cc.sync {
if isSync {
return cc.syncCache(ctxAtWork, contentTypes)
}
cc.cacheWorkerOnce.Do(func() {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/foomo/gocontentful/erm"
)

var VERSION = "v1.0.23"
var VERSION = "v1.0.25"

type contentfulRc struct {
ManagementToken string `json:"managementToken"`
Expand Down
2 changes: 1 addition & 1 deletion test/testapi/gocontentfulvo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/testapi/gocontentfulvobase.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions test/testapi/gocontentfulvolib.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/testapi/gocontentfulvolibbrand.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/testapi/gocontentfulvolibcategory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/testapi/gocontentfulvolibproduct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b9fdad

Please sign in to comment.