Skip to content

Commit

Permalink
Merge pull request #1322 from tyler92/fix-data-race-in-layers
Browse files Browse the repository at this point in the history
Fix data race between ReloadIfChanged and read-only usage of layerStore
  • Loading branch information
rhatdan committed Sep 6, 2022
2 parents 8aa3b3a + a360de2 commit abfc271
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ func (r *layerStore) Load() error {
}
}

info, statErr := os.Stat(r.layerspath())
if statErr != nil && !os.IsNotExist(statErr) {
return statErr
}

if info != nil {
r.layerspathModified = info.ModTime()
}

return err
}

Expand Down Expand Up @@ -1924,7 +1933,6 @@ func (r *layerStore) Modified() (bool, error) {
}
if info != nil {
tmodified = info.ModTime() != r.layerspathModified
r.layerspathModified = info.ModTime()
}

return tmodified, nil
Expand Down

0 comments on commit abfc271

Please sign in to comment.