mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Atomically replace local index cache
This commit is contained in:
parent
d4c5786a14
commit
a2a2e1d466
6
main.go
6
main.go
@ -304,13 +304,15 @@ func updateLocalModel(m *Model) {
|
||||
}
|
||||
|
||||
func saveIndex(m *Model) {
|
||||
fname := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir())))
|
||||
idxf, err := os.Create(path.Join(ConfDir, fname))
|
||||
name := fmt.Sprintf("%x.idx", sha1.Sum([]byte(m.Dir())))
|
||||
fullName := path.Join(ConfDir, name)
|
||||
idxf, err := os.Create(fullName + ".tmp")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
protocol.WriteIndex(idxf, m.ProtocolIndex())
|
||||
idxf.Close()
|
||||
os.Rename(fullName+".tmp", fullName)
|
||||
}
|
||||
|
||||
func loadIndex(m *Model) {
|
||||
|
Loading…
Reference in New Issue
Block a user