|
|
@@ -457,7 +457,7 @@ func (t *readOnlyTransaction) withNeed(folder, device []byte, truncate bool, fn
|
|
|
}
|
|
|
haveFV, have := vl.Get(device)
|
|
|
|
|
|
- if !need(globalFV, have, haveFV.Version) {
|
|
|
+ if !Need(globalFV, have, haveFV.Version) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -630,9 +630,9 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
|
|
|
|
needBefore := false
|
|
|
if haveOldGlobal {
|
|
|
- needBefore = need(oldGlobalFV, haveRemoved, removedFV.Version)
|
|
|
+ needBefore = Need(oldGlobalFV, haveRemoved, removedFV.Version)
|
|
|
}
|
|
|
- needNow := need(globalFV, true, file.Version)
|
|
|
+ needNow := Need(globalFV, true, file.Version)
|
|
|
if needBefore {
|
|
|
if keyBuf, oldGlobal, err = t.getGlobalFromFileVersion(keyBuf, folder, name, true, oldGlobalFV); err != nil {
|
|
|
return nil, false, err
|
|
|
@@ -692,9 +692,9 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
|
localFV, haveLocal := fl.Get(protocol.LocalDeviceID[:])
|
|
|
needBefore := false
|
|
|
if haveOldGlobal {
|
|
|
- needBefore = need(oldGlobalFV, haveLocal, localFV.Version)
|
|
|
+ needBefore = Need(oldGlobalFV, haveLocal, localFV.Version)
|
|
|
}
|
|
|
- needNow := need(globalFV, haveLocal, localFV.Version)
|
|
|
+ needNow := Need(globalFV, haveLocal, localFV.Version)
|
|
|
if needBefore {
|
|
|
meta.removeNeeded(protocol.LocalDeviceID, oldGlobal)
|
|
|
if !needNow {
|
|
|
@@ -703,7 +703,7 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if need(globalFV, haveLocal, localFV.Version) {
|
|
|
+ if Need(globalFV, haveLocal, localFV.Version) {
|
|
|
meta.addNeeded(protocol.LocalDeviceID, global)
|
|
|
if !needBefore {
|
|
|
if keyBuf, err = t.updateLocalNeed(keyBuf, folder, name, true); err != nil {
|
|
|
@@ -719,10 +719,10 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
|
continue
|
|
|
}
|
|
|
fv, have := fl.Get(dev[:])
|
|
|
- if haveOldGlobal && need(oldGlobalFV, have, fv.Version) {
|
|
|
+ if haveOldGlobal && Need(oldGlobalFV, have, fv.Version) {
|
|
|
meta.removeNeeded(dev, oldGlobal)
|
|
|
}
|
|
|
- if need(globalFV, have, fv.Version) {
|
|
|
+ if Need(globalFV, have, fv.Version) {
|
|
|
meta.addNeeded(dev, global)
|
|
|
}
|
|
|
}
|
|
|
@@ -754,7 +754,7 @@ func (t readWriteTransaction) updateLocalNeed(keyBuf, folder, name []byte, add b
|
|
|
return keyBuf, err
|
|
|
}
|
|
|
|
|
|
-func need(global FileVersion, haveLocal bool, localVersion protocol.Vector) bool {
|
|
|
+func Need(global FileVersion, haveLocal bool, localVersion protocol.Vector) bool {
|
|
|
// We never need an invalid file.
|
|
|
if global.IsInvalid() {
|
|
|
return false
|
|
|
@@ -811,7 +811,7 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device, file
|
|
|
|
|
|
globalFV, ok := fl.GetGlobal()
|
|
|
// Add potential needs of the removed device
|
|
|
- if ok && !globalFV.IsInvalid() && need(globalFV, false, protocol.Vector{}) && !need(oldGlobalFV, haveRemoved, removedFV.Version) {
|
|
|
+ if ok && !globalFV.IsInvalid() && Need(globalFV, false, protocol.Vector{}) && !Need(oldGlobalFV, haveRemoved, removedFV.Version) {
|
|
|
keyBuf, global, _, err = t.getGlobalFromVersionList(keyBuf, folder, file, true, fl)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
@@ -842,7 +842,7 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device, file
|
|
|
meta.removeFile(protocol.GlobalDeviceID, f)
|
|
|
|
|
|
// Remove potential device needs
|
|
|
- if fv, have := fl.Get(protocol.LocalDeviceID[:]); need(removedFV, have, fv.Version) {
|
|
|
+ if fv, have := fl.Get(protocol.LocalDeviceID[:]); Need(removedFV, have, fv.Version) {
|
|
|
meta.removeNeeded(protocol.LocalDeviceID, f)
|
|
|
if keyBuf, err = t.updateLocalNeed(keyBuf, folder, file, false); err != nil {
|
|
|
return nil, err
|
|
|
@@ -852,7 +852,7 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device, file
|
|
|
if bytes.Equal(dev[:], device) { // Was the previous global
|
|
|
continue
|
|
|
}
|
|
|
- if fv, have := fl.Get(dev[:]); need(removedFV, have, fv.Version) {
|
|
|
+ if fv, have := fl.Get(dev[:]); Need(removedFV, have, fv.Version) {
|
|
|
meta.removeNeeded(deviceID, f)
|
|
|
}
|
|
|
}
|