We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9676902 commit f0ff827Copy full SHA for f0ff827
devices/linux-client/actions/file_store.go
@@ -125,10 +125,7 @@ func (q *FileStore) removeFile(idx int) error {
125
}
126
127
func (q *FileStore) Reload() error {
128
- q.itemsByIdx = nil
129
-
130
itemsByIdx := make(map[int]FileBlob)
131
132
files, err := ioutil.ReadDir(q.itemsPath())
133
if err != nil {
134
return err
@@ -169,6 +166,11 @@ func (q *FileStore) Reload() error {
169
166
170
167
171
168
+ // After everything was loaded from the filesystem, we can populate the FileStore.
+ // At this point, no errors can happen so we can update the entire object atomically.
+ q.itemsLock.Lock()
172
+ defer q.itemsLock.Unlock()
173
+
174
if minIdx == -1 {
175
q.writeIdx = 0
176
q.readIdx = 0
0 commit comments