mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
This commit is contained in:
parent
40580d8b9b
commit
cf11fa4327
@ -8,19 +8,13 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"errors"
|
||||||
|
|
||||||
"github.com/syncthing/syncthing/lib/db/backend"
|
"github.com/syncthing/syncthing/lib/db/backend"
|
||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
type errDeviceEntryMissing struct {
|
var errEntryFromGlobalMissing = errors.New("device present in global list but missing as device/fileinfo entry")
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (err errDeviceEntryMissing) Error() string {
|
|
||||||
return fmt.Sprintf("device present in global list but missing as device/fileinfo entry: %s", err.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// A readOnlyTransaction represents a database snapshot.
|
// A readOnlyTransaction represents a database snapshot.
|
||||||
type readOnlyTransaction struct {
|
type readOnlyTransaction struct {
|
||||||
@ -364,7 +358,7 @@ func (t *readOnlyTransaction) withNeed(folder, device []byte, truncate bool, fn
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
return errDeviceEntryMissing{string(name)}
|
return errEntryFromGlobalMissing
|
||||||
}
|
}
|
||||||
if !need(gf, have, haveFV.Version) {
|
if !need(gf, have, haveFV.Version) {
|
||||||
continue
|
continue
|
||||||
@ -632,7 +626,7 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device []byte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if f, ok, err := t.getFileByKey(keyBuf); err != nil {
|
if f, ok, err := t.getFileByKey(keyBuf); err != nil {
|
||||||
return keyBuf, nil
|
return nil, err
|
||||||
} else if ok {
|
} else if ok {
|
||||||
meta.removeFile(protocol.GlobalDeviceID, f)
|
meta.removeFile(protocol.GlobalDeviceID, f)
|
||||||
}
|
}
|
||||||
@ -658,8 +652,11 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device []byte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
global, ok, err := t.getFileByKey(keyBuf)
|
global, ok, err := t.getFileByKey(keyBuf)
|
||||||
if err != nil || !ok {
|
if err != nil {
|
||||||
return keyBuf, err
|
return nil, err
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
return nil, errEntryFromGlobalMissing
|
||||||
}
|
}
|
||||||
keyBuf, err = t.updateLocalNeed(keyBuf, folder, file, fl, global)
|
keyBuf, err = t.updateLocalNeed(keyBuf, folder, file, fl, global)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user