lib/db: Handle missing block lists as missing file (ref #6321) (#6322)

Also explicitly handle non-nil but empty block lists (if they should
ever pop up as an effect of unmarshalling changes or whatnot).
This commit is contained in:
Jakob Borg 2020-02-11 15:37:22 +01:00 committed by GitHub
parent 29736b1e33
commit 04e648fee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -550,7 +550,9 @@ func (db *Lowlevel) gcBlocks() error {
if err := bl.Unmarshal(it.Value()); err != nil {
return err
}
filter.Add(bl.BlocksHash)
if len(bl.BlocksHash) > 0 {
filter.Add(bl.BlocksHash)
}
}
it.Release()
if err := it.Error(); err != nil {

View File

@ -59,6 +59,9 @@ func (t readOnlyTransaction) getFileTrunc(key []byte, trunc bool) (FileIntf, boo
return nil, false, err
}
f, err := t.unmarshalTrunc(bs, trunc)
if backend.IsNotFound(err) {
return nil, false, nil
}
if err != nil {
return nil, false, err
}
@ -86,7 +89,7 @@ func (t readOnlyTransaction) unmarshalTrunc(bs []byte, trunc bool) (FileIntf, er
}
func (t readOnlyTransaction) fillBlockList(fi *protocol.FileInfo) error {
if fi.BlocksHash == nil {
if len(fi.BlocksHash) == 0 {
return nil
}
blocksKey := t.keyer.GenerateBlockListKey(nil, fi.BlocksHash)