mirror of
https://github.com/foomo/gocontentful.git
synced 2025-10-16 12:25:39 +00:00
fix: race condition on sync mode
This commit is contained in:
parent
524dd9d61b
commit
9b9fdad2cd
@ -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 {
|
||||
@ -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() {
|
||||
|
||||
2
main.go
2
main.go
@ -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"`
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import "github.com/foomo/contentful"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import (
|
||||
@ -649,6 +649,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 {
|
||||
@ -666,7 +667,7 @@ func (cc *ContentfulClient) UpdateCache(ctx context.Context, contentTypes []stri
|
||||
}
|
||||
}
|
||||
}
|
||||
if cc.sync {
|
||||
if isSync {
|
||||
return cc.syncCache(ctxAtWork, contentTypes)
|
||||
}
|
||||
cc.cacheWorkerOnce.Do(func() {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.23 - DO NOT EDIT.
|
||||
// Code generated by https://github.com/foomo/gocontentful v1.0.24 - DO NOT EDIT.
|
||||
package testapi
|
||||
|
||||
import (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user