1
0
mirror of https://github.com/octoleo/syncthing.git synced 2025-01-02 14:42:00 +00:00

lib/db: Improve error handling checking db (ref ) ()

This commit is contained in:
Simon Frei 2020-10-06 20:14:09 +02:00 committed by GitHub
parent 977ee4f06b
commit 14ae330eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import (
"bytes"
"context"
"encoding/binary"
"fmt"
"io"
"os"
"time"
@ -822,6 +823,7 @@ func (db *Lowlevel) getMetaAndCheck(folder string) *metadataTracker {
var fixed int
fixed, err = db.checkLocalNeed([]byte(folder))
if err != nil {
err = fmt.Errorf("checking local need: %w", err)
return nil
}
if fixed != 0 {
@ -830,11 +832,13 @@ func (db *Lowlevel) getMetaAndCheck(folder string) *metadataTracker {
meta, err := db.recalcMeta(folder)
if err != nil {
err = fmt.Errorf("recalculating metadata: %w", err)
return nil
}
fixed, err = db.repairSequenceGCLocked(folder, meta)
if err != nil {
err = fmt.Errorf("repairing sequences: %w", err)
return nil
}
if fixed != 0 {
@ -1094,7 +1098,7 @@ func (db *Lowlevel) checkLocalNeed(folder []byte) (int, error) {
f := fi.(FileInfoTruncated)
for !needDone && needName < f.Name {
repaired++
if err = t.Delete(dbi.Key()); err != nil {
if err = t.Delete(dbi.Key()); err != nil && !backend.IsNotFound(err) {
return false
}
l.Debugln("check local need: removing", needName)
@ -1121,7 +1125,7 @@ func (db *Lowlevel) checkLocalNeed(folder []byte) (int, error) {
for !needDone {
repaired++
if err := t.Delete(dbi.Key()); err != nil {
if err := t.Delete(dbi.Key()); err != nil && !backend.IsNotFound(err) {
return 0, err
}
l.Debugln("check local need: removing", needName)