mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
Tick version clock on load
This commit is contained in:
parent
91cc0cd05e
commit
ec212f73eb
@ -437,6 +437,40 @@ func ldbWithAllRepo(db *leveldb.DB, repo []byte, fn func(node []byte, f protocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func ldbCheckGlobalConsistency(db *leveldb.DB, repo []byte) {
|
||||||
|
l.Debugf("Checking global consistency for %q", repo)
|
||||||
|
start := nodeKey(repo, nil, nil) // before all repo/node files
|
||||||
|
limit := nodeKey(repo, protocol.LocalNodeID[:], []byte{0xff, 0xff, 0xff, 0xff}) // after all repo/node files
|
||||||
|
snap, err := db.GetSnapshot()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer snap.Release()
|
||||||
|
dbi := snap.NewIterator(&util.Range{Start: start, Limit: limit}, nil)
|
||||||
|
defer dbi.Release()
|
||||||
|
|
||||||
|
batch := new(leveldb.Batch)
|
||||||
|
i := 0
|
||||||
|
for dbi.Next() {
|
||||||
|
repo := nodeKeyRepo(dbi.Key())
|
||||||
|
node := nodeKeyNode(dbi.Key())
|
||||||
|
var f protocol.FileInfo
|
||||||
|
err := f.UnmarshalXDR(dbi.Value())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if ldbUpdateGlobal(snap, batch, repo, node, []byte(f.Name), f.Version) {
|
||||||
|
var nodeID protocol.NodeID
|
||||||
|
copy(nodeID[:], node)
|
||||||
|
l.Debugf("fixed global for %q %s %q", repo, nodeID, f.Name)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
l.Debugln("Done", i)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func ldbGet(db *leveldb.DB, repo, node, file []byte) protocol.FileInfo {
|
func ldbGet(db *leveldb.DB, repo, node, file []byte) protocol.FileInfo {
|
||||||
nk := nodeKey(repo, node, file)
|
nk := nodeKey(repo, node, file)
|
||||||
bs, err := db.Get(nk, nil)
|
bs, err := db.Get(nk, nil)
|
||||||
|
@ -8,6 +8,7 @@ package files
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/calmh/syncthing/lamport"
|
||||||
"github.com/calmh/syncthing/protocol"
|
"github.com/calmh/syncthing/protocol"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
)
|
)
|
||||||
@ -40,6 +41,7 @@ func NewSet(repo string, db *leveldb.DB) *Set {
|
|||||||
if f.LocalVersion > s.localVersion[nodeID] {
|
if f.LocalVersion > s.localVersion[nodeID] {
|
||||||
s.localVersion[nodeID] = f.LocalVersion
|
s.localVersion[nodeID] = f.LocalVersion
|
||||||
}
|
}
|
||||||
|
lamport.Default.Tick(f.Version)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if debug {
|
if debug {
|
||||||
|
Loading…
Reference in New Issue
Block a user