Lock state store when saving/loading and update deps

This commit is contained in:
Tulir Asokan
2018-12-16 21:27:37 +02:00
parent c6d33d8bba
commit bb3d67dba9
163 changed files with 25522 additions and 9464 deletions

View File

@@ -38,6 +38,8 @@ func NewAutosavingStateStore(path string) *AutosavingStateStore {
}
func (store *AutosavingStateStore) Save() error {
store.RLock()
defer store.RUnlock()
data, err := json.Marshal(store.StateStore)
if err != nil {
return err
@@ -47,6 +49,8 @@ func (store *AutosavingStateStore) Save() error {
}
func (store *AutosavingStateStore) Load() error {
store.Lock()
defer store.Unlock()
data, err := ioutil.ReadFile(store.Path)
if err != nil {
if os.IsNotExist(err) {