|
@@ -662,11 +662,13 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // Update global size counter.
|
|
|
|
- // It's done regardless of if the global changed, as two files might
|
|
|
|
- // both be invalid, but for different reasons i.e. have different flags
|
|
|
|
- // (e.g. ignored vs receive only).
|
|
|
|
- // https://github.com/syncthing/syncthing/issues/6850
|
|
|
|
|
|
+ // Update global size counter if necessary
|
|
|
|
+
|
|
|
|
+ if !globalChanged {
|
|
|
|
+ // Neither the global state nor the needs of any devices, except
|
|
|
|
+ // the one updated, changed.
|
|
|
|
+ return keyBuf, true, nil
|
|
|
|
+ }
|
|
|
|
|
|
// Remove the old global from the global size counter
|
|
// Remove the old global from the global size counter
|
|
if haveOldGlobal {
|
|
if haveOldGlobal {
|
|
@@ -689,12 +691,6 @@ func (t readWriteTransaction) updateGlobal(gk, keyBuf, folder, device []byte, fi
|
|
}
|
|
}
|
|
meta.addFile(protocol.GlobalDeviceID, global)
|
|
meta.addFile(protocol.GlobalDeviceID, global)
|
|
|
|
|
|
- if !globalChanged {
|
|
|
|
- // Neither the global state nor the needs of any devices, except
|
|
|
|
- // the one updated, changed.
|
|
|
|
- return keyBuf, true, nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// check for local (if not already done before)
|
|
// check for local (if not already done before)
|
|
if !bytes.Equal(device, protocol.LocalDeviceID[:]) {
|
|
if !bytes.Equal(device, protocol.LocalDeviceID[:]) {
|
|
localFV, haveLocal := fl.Get(protocol.LocalDeviceID[:])
|
|
localFV, haveLocal := fl.Get(protocol.LocalDeviceID[:])
|
|
@@ -842,15 +838,10 @@ func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device, file
|
|
return keyBuf, nil
|
|
return keyBuf, nil
|
|
}
|
|
}
|
|
|
|
|
|
- keyBuf, err = t.keyer.GenerateDeviceFileKey(keyBuf, folder, device, file)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, err
|
|
|
|
- }
|
|
|
|
- f, ok, err := t.getFileTrunc(keyBuf, true)
|
|
|
|
|
|
+ var f protocol.FileIntf
|
|
|
|
+ keyBuf, f, err = t.getGlobalFromFileVersion(keyBuf, folder, file, true, oldGlobalFV)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
- } else if !ok {
|
|
|
|
- return nil, errEntryFromGlobalMissing
|
|
|
|
}
|
|
}
|
|
meta.removeFile(protocol.GlobalDeviceID, f)
|
|
meta.removeFile(protocol.GlobalDeviceID, f)
|
|
|
|
|