mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-31 22:11:51 +00:00
Compact database on startup (ref #2400)
This commit is contained in:
parent
02f044a2a1
commit
fa4b4dece1
@ -639,6 +639,13 @@ func syncthingMain() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pack and optimize the database
|
||||||
|
if err := ldb.Compact(); err != nil {
|
||||||
|
// I don't think this is fatal, but who knows. If it is, we'll surely
|
||||||
|
// get an error when trying to write to the db later.
|
||||||
|
l.Infoln("Compacting database:", err)
|
||||||
|
}
|
||||||
|
|
||||||
m := model.NewModel(cfg, myID, myName, "syncthing", Version, ldb, protectedFiles)
|
m := model.NewModel(cfg, myID, myName, "syncthing", Version, ldb, protectedFiles)
|
||||||
cfg.Subscribe(m)
|
cfg.Subscribe(m)
|
||||||
|
|
||||||
|
@ -65,6 +65,10 @@ func newDBInstance(db *leveldb.DB) *Instance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Instance) Compact() error {
|
||||||
|
return db.CompactRange(util.Range{})
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Instance) genericReplace(folder, device []byte, fs []protocol.FileInfo, localSize, globalSize *sizeTracker, deleteFn deletionHandler) int64 {
|
func (db *Instance) genericReplace(folder, device []byte, fs []protocol.FileInfo, localSize, globalSize *sizeTracker, deleteFn deletionHandler) int64 {
|
||||||
sort.Sort(fileList(fs)) // sort list on name, same as in the database
|
sort.Sort(fileList(fs)) // sort list on name, same as in the database
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user