lib/model: Fix reverting when version has only our own ID (fixes #7708) (#7714)

This commit is contained in:
Simon Frei
2021-06-03 15:08:56 +02:00
committed by GitHub
parent 004eded398
commit 855c53ad02
2 changed files with 77 additions and 5 deletions
+13 -5
View File
@@ -100,9 +100,15 @@ func (f *receiveOnlyFolder) revert() error {
}
fi.LocalFlags &^= protocol.FlagLocalReceiveOnly
if len(fi.Version.Counters) == 1 && fi.Version.Counters[0].ID == f.shortID {
// We are the only device mentioned in the version vector so the
// file must originate here. A revert then means to delete it.
switch gf, ok := snap.GetGlobal(fi.Name); {
case !ok:
msg := "Unexpected global file that we have locally"
l.Debugf("%v revert: %v: %v", f, msg, fi.Name)
f.evLogger.Log(events.Failure, msg)
return true
case gf.IsReceiveOnlyChanged():
// The global file is our own. A revert then means to delete it.
// We'll delete files directly, directories get queued and
// handled below.
@@ -114,10 +120,12 @@ func (f *receiveOnlyFolder) revert() error {
if !handled {
return true // continue
}
fi.SetDeleted(f.shortID)
fi.Version = protocol.Vector{} // if this file ever resurfaces anywhere we want our delete to be strictly older
} else {
case gf.IsEquivalentOptional(fi, f.modTimeWindow, false, false, protocol.FlagLocalReceiveOnly):
// What we have locally is equivalent to the global file.
fi = gf
default:
// Revert means to throw away our local changes. We reset the
// version to the empty vector, which is strictly older than any
// other existing version. It is not in conflict with anything,