lib: Do not set ModifiedBy on meta only changes (#7345)

This commit is contained in:
Simon Frei 2021-02-08 15:30:39 +01:00 committed by GitHub
parent e95d005c21
commit c0f353c0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 22 deletions

View File

@ -748,7 +748,7 @@ func (db *schemaUpdater) updateSchemaTo14(_ int) error {
continue
}
fi.SetMustRescan(protocol.LocalDeviceID.Short())
fi.SetMustRescan()
if err = t.putFile(it.Key(), fi); err != nil {
return err
}

View File

@ -1354,7 +1354,7 @@ func TestNeedAfterUnignore(t *testing.T) {
// Initial state: Devices in sync, locally ignored
local := protocol.FileInfo{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: remID, Value: 1}, {ID: myID, Value: 1}}}, ModifiedS: 10}
local.SetIgnored(myID)
local.SetIgnored()
remote := protocol.FileInfo{Name: file, Version: protocol.Vector{Counters: []protocol.Counter{{ID: remID, Value: 1}, {ID: myID, Value: 1}}}, ModifiedS: 10}
s.Update(protocol.LocalDeviceID, fileList{local})
s.Update(remoteDevice0, fileList{remote})

View File

@ -125,9 +125,9 @@ func (f FileInfoTruncated) FileModifiedBy() protocol.ShortID {
return f.ModifiedBy
}
func (f FileInfoTruncated) ConvertToIgnoredFileInfo(by protocol.ShortID) protocol.FileInfo {
func (f FileInfoTruncated) ConvertToIgnoredFileInfo() protocol.FileInfo {
file := f.copyToFileInfo()
file.SetIgnored(by)
file.SetIgnored()
return file
}

View File

@ -652,7 +652,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
if ignoredParent != "" && !fs.IsParent(file.Name, ignoredParent) {
for _, file := range toIgnore {
l.Debugln("marking file as ignored", file)
nf := file.ConvertToIgnoredFileInfo(f.shortID)
nf := file.ConvertToIgnoredFileInfo()
if batchAppend(nf, snap) {
changes++
}
@ -682,7 +682,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
}
l.Debugln("marking file as ignored", file)
nf := file.ConvertToIgnoredFileInfo(f.shortID)
nf := file.ConvertToIgnoredFileInfo()
if batchAppend(nf, snap) {
changes++
}
@ -745,7 +745,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
if iterError == nil && len(toIgnore) > 0 {
for _, file := range toIgnore {
l.Debugln("marking file as ignored", f)
nf := file.ConvertToIgnoredFileInfo(f.shortID)
nf := file.ConvertToIgnoredFileInfo()
if batchAppend(nf, snap) {
changes++
}
@ -1192,7 +1192,7 @@ func (f *folder) handleForcedRescans() {
if !ok {
continue
}
fi.SetMustRescan(f.shortID)
fi.SetMustRescan()
batch.append(fi)
}

View File

@ -51,7 +51,7 @@ func (f *sendOnlyFolder) pull() bool {
if f.ignores.ShouldIgnore(intf.FileName()) {
file := intf.(protocol.FileInfo)
file.SetIgnored(f.shortID)
file.SetIgnored()
batch = append(batch, file)
batchSizeBytes += file.ProtoSize()
l.Debugln(f, "Handling ignored file", file)

View File

@ -331,7 +331,7 @@ func (f *sendReceiveFolder) processNeeded(snap *db.Snapshot, dbUpdateChan chan<-
switch {
case f.ignores.ShouldIgnore(file.Name):
file.SetIgnored(f.shortID)
file.SetIgnored()
l.Debugln(f, "Handling ignored file", file)
dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
@ -390,7 +390,7 @@ func (f *sendReceiveFolder) processNeeded(snap *db.Snapshot, dbUpdateChan chan<-
f.newPullError(file.Name, fmt.Errorf("handling unsupported symlink: %w", err))
break
}
file.SetUnsupported(f.shortID)
file.SetUnsupported()
l.Debugln(f, "Invalidating symlink (unsupported)", file.Name)
dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}

View File

@ -297,16 +297,16 @@ func blocksEqual(a, b []BlockInfo) bool {
return true
}
func (f *FileInfo) SetMustRescan(by ShortID) {
f.setLocalFlags(by, FlagLocalMustRescan)
func (f *FileInfo) SetMustRescan() {
f.setLocalFlags(FlagLocalMustRescan)
}
func (f *FileInfo) SetIgnored(by ShortID) {
f.setLocalFlags(by, FlagLocalIgnored)
func (f *FileInfo) SetIgnored() {
f.setLocalFlags(FlagLocalIgnored)
}
func (f *FileInfo) SetUnsupported(by ShortID) {
f.setLocalFlags(by, FlagLocalUnsupported)
func (f *FileInfo) SetUnsupported() {
f.setLocalFlags(FlagLocalUnsupported)
}
func (f *FileInfo) SetDeleted(by ShortID) {
@ -317,10 +317,9 @@ func (f *FileInfo) SetDeleted(by ShortID) {
f.setNoContent()
}
func (f *FileInfo) setLocalFlags(by ShortID, flags uint32) {
func (f *FileInfo) setLocalFlags(flags uint32) {
f.RawInvalid = false
f.LocalFlags = flags
f.ModifiedBy = by
f.setNoContent()
}

View File

@ -635,17 +635,17 @@ func TestLocalFlagBits(t *testing.T) {
t.Error("file should have no weird bits set by default")
}
f.SetIgnored(42)
f.SetIgnored()
if !f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
t.Error("file should be ignored and invalid")
}
f.SetMustRescan(42)
f.SetMustRescan()
if f.IsIgnored() || !f.MustRescan() || !f.IsInvalid() {
t.Error("file should be must-rescan and invalid")
}
f.SetUnsupported(42)
f.SetUnsupported()
if f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
t.Error("file should be invalid")
}