mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 09:14:10 +00:00
(Re)Fix locking around deleteFile (fixes #64)
This commit is contained in:
parent
478300f6d8
commit
a26ce61d92
@ -221,6 +221,8 @@ func (q *FileQueue) SetAvailable(file string, nodes []string) {
|
|||||||
|
|
||||||
func (q *FileQueue) RemoveAvailable(toRemove string) {
|
func (q *FileQueue) RemoveAvailable(toRemove string) {
|
||||||
q.amut.Lock()
|
q.amut.Lock()
|
||||||
|
q.fmut.Lock()
|
||||||
|
defer q.fmut.Unlock()
|
||||||
defer q.amut.Unlock()
|
defer q.amut.Unlock()
|
||||||
|
|
||||||
for file, nodes := range q.availability {
|
for file, nodes := range q.availability {
|
||||||
@ -228,9 +230,7 @@ func (q *FileQueue) RemoveAvailable(toRemove string) {
|
|||||||
if node == toRemove {
|
if node == toRemove {
|
||||||
q.availability[file] = nodes[:i+copy(nodes[i:], nodes[i+1:])]
|
q.availability[file] = nodes[:i+copy(nodes[i:], nodes[i+1:])]
|
||||||
if len(q.availability[file]) == 0 {
|
if len(q.availability[file]) == 0 {
|
||||||
q.fmut.Lock()
|
|
||||||
q.deleteFile(file)
|
q.deleteFile(file)
|
||||||
q.fmut.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user