mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
parent
d1e0a38c04
commit
52e72e0122
@ -488,8 +488,18 @@ func (db *Lowlevel) dropPrefix(prefix []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *Lowlevel) gcRunner() {
|
func (db *Lowlevel) gcRunner() {
|
||||||
t := time.NewTimer(db.timeUntil(indirectGCTimeKey, indirectGCInterval))
|
// Calculate the time for the next GC run. Even if we should run GC
|
||||||
|
// directly, give the system a while to get up and running and do other
|
||||||
|
// stuff first. (We might have migrations and stuff which would be
|
||||||
|
// better off running before GC.)
|
||||||
|
next := db.timeUntil(indirectGCTimeKey, indirectGCInterval)
|
||||||
|
if next < time.Minute {
|
||||||
|
next = time.Minute
|
||||||
|
}
|
||||||
|
|
||||||
|
t := time.NewTimer(next)
|
||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-db.gcStop:
|
case <-db.gcStop:
|
||||||
@ -558,10 +568,11 @@ func (db *Lowlevel) gcIndirect() error {
|
|||||||
// Iterate the FileInfos, unmarshal the block and version hashes and
|
// Iterate the FileInfos, unmarshal the block and version hashes and
|
||||||
// add them to the filter.
|
// add them to the filter.
|
||||||
|
|
||||||
it, err := db.NewPrefixIterator([]byte{KeyTypeDevice})
|
it, err := t.NewPrefixIterator([]byte{KeyTypeDevice})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer it.Release()
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
var bl BlocksHashOnly
|
var bl BlocksHashOnly
|
||||||
if err := bl.Unmarshal(it.Value()); err != nil {
|
if err := bl.Unmarshal(it.Value()); err != nil {
|
||||||
@ -579,10 +590,11 @@ func (db *Lowlevel) gcIndirect() error {
|
|||||||
// Iterate over block lists, removing keys with hashes that don't match
|
// Iterate over block lists, removing keys with hashes that don't match
|
||||||
// the filter.
|
// the filter.
|
||||||
|
|
||||||
it, err = db.NewPrefixIterator([]byte{KeyTypeBlockList})
|
it, err = t.NewPrefixIterator([]byte{KeyTypeBlockList})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer it.Release()
|
||||||
matchedBlocks := 0
|
matchedBlocks := 0
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
key := blockListKey(it.Key())
|
key := blockListKey(it.Key())
|
||||||
|
@ -57,6 +57,11 @@ type schemaUpdater struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *schemaUpdater) updateSchema() error {
|
func (db *schemaUpdater) updateSchema() error {
|
||||||
|
// Updating the schema can touch any and all parts of the database. Make
|
||||||
|
// sure we do not run GC concurrently with schema migrations.
|
||||||
|
db.gcMut.Lock()
|
||||||
|
defer db.gcMut.Unlock()
|
||||||
|
|
||||||
miscDB := NewMiscDataNamespace(db.Lowlevel)
|
miscDB := NewMiscDataNamespace(db.Lowlevel)
|
||||||
prevVersion, _, err := miscDB.Int64("dbVersion")
|
prevVersion, _, err := miscDB.Int64("dbVersion")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user