mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
lib: Do not set ModifiedBy on meta only changes (#7345)
This commit is contained in:
parent
e95d005c21
commit
c0f353c0e8
@ -748,7 +748,7 @@ func (db *schemaUpdater) updateSchemaTo14(_ int) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fi.SetMustRescan(protocol.LocalDeviceID.Short())
|
fi.SetMustRescan()
|
||||||
if err = t.putFile(it.Key(), fi); err != nil {
|
if err = t.putFile(it.Key(), fi); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1354,7 +1354,7 @@ func TestNeedAfterUnignore(t *testing.T) {
|
|||||||
|
|
||||||
// Initial state: Devices in sync, locally ignored
|
// 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 := 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}
|
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(protocol.LocalDeviceID, fileList{local})
|
||||||
s.Update(remoteDevice0, fileList{remote})
|
s.Update(remoteDevice0, fileList{remote})
|
||||||
|
@ -125,9 +125,9 @@ func (f FileInfoTruncated) FileModifiedBy() protocol.ShortID {
|
|||||||
return f.ModifiedBy
|
return f.ModifiedBy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileInfoTruncated) ConvertToIgnoredFileInfo(by protocol.ShortID) protocol.FileInfo {
|
func (f FileInfoTruncated) ConvertToIgnoredFileInfo() protocol.FileInfo {
|
||||||
file := f.copyToFileInfo()
|
file := f.copyToFileInfo()
|
||||||
file.SetIgnored(by)
|
file.SetIgnored()
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
|
|||||||
if ignoredParent != "" && !fs.IsParent(file.Name, ignoredParent) {
|
if ignoredParent != "" && !fs.IsParent(file.Name, ignoredParent) {
|
||||||
for _, file := range toIgnore {
|
for _, file := range toIgnore {
|
||||||
l.Debugln("marking file as ignored", file)
|
l.Debugln("marking file as ignored", file)
|
||||||
nf := file.ConvertToIgnoredFileInfo(f.shortID)
|
nf := file.ConvertToIgnoredFileInfo()
|
||||||
if batchAppend(nf, snap) {
|
if batchAppend(nf, snap) {
|
||||||
changes++
|
changes++
|
||||||
}
|
}
|
||||||
@ -682,7 +682,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
|
|||||||
}
|
}
|
||||||
|
|
||||||
l.Debugln("marking file as ignored", file)
|
l.Debugln("marking file as ignored", file)
|
||||||
nf := file.ConvertToIgnoredFileInfo(f.shortID)
|
nf := file.ConvertToIgnoredFileInfo()
|
||||||
if batchAppend(nf, snap) {
|
if batchAppend(nf, snap) {
|
||||||
changes++
|
changes++
|
||||||
}
|
}
|
||||||
@ -745,7 +745,7 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *fileInfoB
|
|||||||
if iterError == nil && len(toIgnore) > 0 {
|
if iterError == nil && len(toIgnore) > 0 {
|
||||||
for _, file := range toIgnore {
|
for _, file := range toIgnore {
|
||||||
l.Debugln("marking file as ignored", f)
|
l.Debugln("marking file as ignored", f)
|
||||||
nf := file.ConvertToIgnoredFileInfo(f.shortID)
|
nf := file.ConvertToIgnoredFileInfo()
|
||||||
if batchAppend(nf, snap) {
|
if batchAppend(nf, snap) {
|
||||||
changes++
|
changes++
|
||||||
}
|
}
|
||||||
@ -1192,7 +1192,7 @@ func (f *folder) handleForcedRescans() {
|
|||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fi.SetMustRescan(f.shortID)
|
fi.SetMustRescan()
|
||||||
batch.append(fi)
|
batch.append(fi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func (f *sendOnlyFolder) pull() bool {
|
|||||||
|
|
||||||
if f.ignores.ShouldIgnore(intf.FileName()) {
|
if f.ignores.ShouldIgnore(intf.FileName()) {
|
||||||
file := intf.(protocol.FileInfo)
|
file := intf.(protocol.FileInfo)
|
||||||
file.SetIgnored(f.shortID)
|
file.SetIgnored()
|
||||||
batch = append(batch, file)
|
batch = append(batch, file)
|
||||||
batchSizeBytes += file.ProtoSize()
|
batchSizeBytes += file.ProtoSize()
|
||||||
l.Debugln(f, "Handling ignored file", file)
|
l.Debugln(f, "Handling ignored file", file)
|
||||||
|
@ -331,7 +331,7 @@ func (f *sendReceiveFolder) processNeeded(snap *db.Snapshot, dbUpdateChan chan<-
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case f.ignores.ShouldIgnore(file.Name):
|
case f.ignores.ShouldIgnore(file.Name):
|
||||||
file.SetIgnored(f.shortID)
|
file.SetIgnored()
|
||||||
l.Debugln(f, "Handling ignored file", file)
|
l.Debugln(f, "Handling ignored file", file)
|
||||||
dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
|
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))
|
f.newPullError(file.Name, fmt.Errorf("handling unsupported symlink: %w", err))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
file.SetUnsupported(f.shortID)
|
file.SetUnsupported()
|
||||||
l.Debugln(f, "Invalidating symlink (unsupported)", file.Name)
|
l.Debugln(f, "Invalidating symlink (unsupported)", file.Name)
|
||||||
dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
|
dbUpdateChan <- dbUpdateJob{file, dbUpdateInvalidate}
|
||||||
|
|
||||||
|
@ -297,16 +297,16 @@ func blocksEqual(a, b []BlockInfo) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileInfo) SetMustRescan(by ShortID) {
|
func (f *FileInfo) SetMustRescan() {
|
||||||
f.setLocalFlags(by, FlagLocalMustRescan)
|
f.setLocalFlags(FlagLocalMustRescan)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileInfo) SetIgnored(by ShortID) {
|
func (f *FileInfo) SetIgnored() {
|
||||||
f.setLocalFlags(by, FlagLocalIgnored)
|
f.setLocalFlags(FlagLocalIgnored)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileInfo) SetUnsupported(by ShortID) {
|
func (f *FileInfo) SetUnsupported() {
|
||||||
f.setLocalFlags(by, FlagLocalUnsupported)
|
f.setLocalFlags(FlagLocalUnsupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileInfo) SetDeleted(by ShortID) {
|
func (f *FileInfo) SetDeleted(by ShortID) {
|
||||||
@ -317,10 +317,9 @@ func (f *FileInfo) SetDeleted(by ShortID) {
|
|||||||
f.setNoContent()
|
f.setNoContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileInfo) setLocalFlags(by ShortID, flags uint32) {
|
func (f *FileInfo) setLocalFlags(flags uint32) {
|
||||||
f.RawInvalid = false
|
f.RawInvalid = false
|
||||||
f.LocalFlags = flags
|
f.LocalFlags = flags
|
||||||
f.ModifiedBy = by
|
|
||||||
f.setNoContent()
|
f.setNoContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,17 +635,17 @@ func TestLocalFlagBits(t *testing.T) {
|
|||||||
t.Error("file should have no weird bits set by default")
|
t.Error("file should have no weird bits set by default")
|
||||||
}
|
}
|
||||||
|
|
||||||
f.SetIgnored(42)
|
f.SetIgnored()
|
||||||
if !f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
|
if !f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
|
||||||
t.Error("file should be ignored and invalid")
|
t.Error("file should be ignored and invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
f.SetMustRescan(42)
|
f.SetMustRescan()
|
||||||
if f.IsIgnored() || !f.MustRescan() || !f.IsInvalid() {
|
if f.IsIgnored() || !f.MustRescan() || !f.IsInvalid() {
|
||||||
t.Error("file should be must-rescan and invalid")
|
t.Error("file should be must-rescan and invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
f.SetUnsupported(42)
|
f.SetUnsupported()
|
||||||
if f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
|
if f.IsIgnored() || f.MustRescan() || !f.IsInvalid() {
|
||||||
t.Error("file should be invalid")
|
t.Error("file should be invalid")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user