|
|
@@ -99,31 +99,6 @@ func (t readWriteTransaction) updateGlobal(gk, folder, device []byte, file proto
|
|
|
|
|
|
name := []byte(file.Name)
|
|
|
|
|
|
- if removedAt != 0 && insertedAt != 0 {
|
|
|
- if bytes.Equal(device, protocol.LocalDeviceID[:]) && file.Version.Equal(fl.Versions[0].Version) {
|
|
|
- l.Debugf("local need delete; folder=%q, name=%q", folder, name)
|
|
|
- t.Delete(t.db.needKey(folder, name))
|
|
|
- }
|
|
|
- l.Debugf(`new global for "%v" after update: %v`, file.Name, fl)
|
|
|
- t.Put(gk, mustMarshal(&fl))
|
|
|
- return true
|
|
|
- }
|
|
|
-
|
|
|
- // Remove the old global from the global size counter
|
|
|
- var oldGlobalFV FileVersion
|
|
|
- if removedAt == 0 {
|
|
|
- oldGlobalFV = removedFV
|
|
|
- } else if len(fl.Versions) > 1 {
|
|
|
- // The previous newest version is now at index 1
|
|
|
- oldGlobalFV = fl.Versions[1]
|
|
|
- }
|
|
|
- if oldFile, ok := t.getFile(folder, oldGlobalFV.Device, name); ok {
|
|
|
- // A failure to get the file here is surprising and our
|
|
|
- // global size data will be incorrect until a restart...
|
|
|
- meta.removeFile(globalDeviceID, oldFile)
|
|
|
- }
|
|
|
-
|
|
|
- // Add the new global to the global size counter
|
|
|
var newGlobal protocol.FileInfo
|
|
|
if insertedAt == 0 {
|
|
|
// Inserted a new newest version
|
|
|
@@ -134,7 +109,6 @@ func (t readWriteTransaction) updateGlobal(gk, folder, device []byte, file proto
|
|
|
} else {
|
|
|
panic("This file must exist in the db")
|
|
|
}
|
|
|
- meta.addFile(globalDeviceID, newGlobal)
|
|
|
|
|
|
// Fixup the list of files we need.
|
|
|
nk := t.db.needKey(folder, name)
|
|
|
@@ -149,6 +123,29 @@ func (t readWriteTransaction) updateGlobal(gk, folder, device []byte, file proto
|
|
|
t.Delete(nk)
|
|
|
}
|
|
|
|
|
|
+ if removedAt != 0 && insertedAt != 0 {
|
|
|
+ l.Debugf(`new global for "%v" after update: %v`, file.Name, fl)
|
|
|
+ t.Put(gk, mustMarshal(&fl))
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove the old global from the global size counter
|
|
|
+ var oldGlobalFV FileVersion
|
|
|
+ if removedAt == 0 {
|
|
|
+ oldGlobalFV = removedFV
|
|
|
+ } else if len(fl.Versions) > 1 {
|
|
|
+ // The previous newest version is now at index 1
|
|
|
+ oldGlobalFV = fl.Versions[1]
|
|
|
+ }
|
|
|
+ if oldFile, ok := t.getFile(folder, oldGlobalFV.Device, name); ok {
|
|
|
+ // A failure to get the file here is surprising and our
|
|
|
+ // global size data will be incorrect until a restart...
|
|
|
+ meta.removeFile(globalDeviceID, oldFile)
|
|
|
+ }
|
|
|
+
|
|
|
+ // Add the new global to the global size counter
|
|
|
+ meta.addFile(globalDeviceID, newGlobal)
|
|
|
+
|
|
|
l.Debugf(`new global for "%v" after update: %v`, file.Name, fl)
|
|
|
t.Put(gk, mustMarshal(&fl))
|
|
|
|