+9
-8
@@ -601,14 +601,15 @@ func (b *scanBatch) Update(fi protocol.FileInfo, snap *db.Snapshot) bool {
|
|||||||
b.Remove(fi.Name)
|
b.Remove(fi.Name)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
case gf.IsEquivalentOptional(fi, protocol.FileInfoComparison{
|
case (b.f.Type == config.FolderTypeReceiveOnly || b.f.Type == config.FolderTypeReceiveEncrypted) &&
|
||||||
ModTimeWindow: b.f.modTimeWindow,
|
gf.IsEquivalentOptional(fi, protocol.FileInfoComparison{
|
||||||
IgnorePerms: b.f.IgnorePerms,
|
ModTimeWindow: b.f.modTimeWindow,
|
||||||
IgnoreBlocks: true,
|
IgnorePerms: b.f.IgnorePerms,
|
||||||
IgnoreFlags: protocol.FlagLocalReceiveOnly,
|
IgnoreBlocks: true,
|
||||||
IgnoreOwnership: !b.f.SyncOwnership,
|
IgnoreFlags: protocol.FlagLocalReceiveOnly,
|
||||||
IgnoreXattrs: !b.f.SyncXattrs,
|
IgnoreOwnership: !b.f.SyncOwnership && !b.f.SendOwnership,
|
||||||
}):
|
IgnoreXattrs: !b.f.SyncXattrs && !b.f.SendXattrs,
|
||||||
|
}):
|
||||||
// What we have locally is equivalent to the global file.
|
// What we have locally is equivalent to the global file.
|
||||||
l.Debugf("%v scanning: Merging identical locally changed item with global", b.f, fi)
|
l.Debugf("%v scanning: Merging identical locally changed item with global", b.f, fi)
|
||||||
fi = gf
|
fi = gf
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ func (f FileInfo) isEquivalent(other FileInfo, comp FileInfoComparison) bool {
|
|||||||
|
|
||||||
// If we are recording inode change times and it changed, they are not
|
// If we are recording inode change times and it changed, they are not
|
||||||
// equal.
|
// equal.
|
||||||
if f.InodeChangeNs != 0 && other.InodeChangeNs != 0 && f.InodeChangeNs != other.InodeChangeNs {
|
if (f.InodeChangeNs != 0 && other.InodeChangeNs != 0) && f.InodeChangeNs != other.InodeChangeNs {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,21 +258,12 @@ func (f FileInfo) isEquivalent(other FileInfo, comp FileInfoComparison) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// OS data comparison is special: we consider a difference only if an
|
|
||||||
// entry for the same OS exists on both sides and they are different.
|
|
||||||
// Otherwise a file would become different as soon as it's synced from
|
|
||||||
// Windows to Linux, as Linux would add a new POSIX entry for the file.
|
|
||||||
if !comp.IgnoreOwnership && f.Platform != other.Platform {
|
if !comp.IgnoreOwnership && f.Platform != other.Platform {
|
||||||
if f.Platform.Unix != nil && other.Platform.Unix != nil {
|
if !unixOwnershipEqual(f.Platform.Unix, other.Platform.Unix) {
|
||||||
if *f.Platform.Unix != *other.Platform.Unix {
|
return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if f.Platform.Windows != nil && other.Platform.Windows != nil {
|
if !windowsOwnershipEqual(f.Platform.Windows, other.Platform.Windows) {
|
||||||
if f.Platform.Windows.OwnerName != other.Platform.Windows.OwnerName ||
|
return false
|
||||||
f.Platform.Windows.OwnerIsGroup != other.Platform.Windows.OwnerIsGroup {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !comp.IgnoreXattrs && f.Platform != other.Platform {
|
if !comp.IgnoreXattrs && f.Platform != other.Platform {
|
||||||
@@ -542,11 +533,15 @@ func (x *FileInfoType) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func xattrsEqual(a, b *XattrData) bool {
|
func xattrsEqual(a, b *XattrData) bool {
|
||||||
if a == nil || b == nil {
|
aEmpty := a == nil || len(a.Xattrs) == 0
|
||||||
// Having no data on either side means we have nothing to compare
|
bEmpty := b == nil || len(b.Xattrs) == 0
|
||||||
// to, and we consider that equal.
|
if aEmpty && bEmpty {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if aEmpty || bEmpty {
|
||||||
|
// Only one side is empty, so they can't be equal.
|
||||||
|
return false
|
||||||
|
}
|
||||||
if len(a.Xattrs) != len(b.Xattrs) {
|
if len(a.Xattrs) != len(b.Xattrs) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -560,3 +555,23 @@ func xattrsEqual(a, b *XattrData) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unixOwnershipEqual(a, b *UnixData) bool {
|
||||||
|
if a == nil && b == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if a == nil || b == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return a.UID == b.UID && a.GID == b.GID && a.OwnerName == b.OwnerName && a.GroupName == b.GroupName
|
||||||
|
}
|
||||||
|
|
||||||
|
func windowsOwnershipEqual(a, b *WindowsData) bool {
|
||||||
|
if a == nil && b == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if a == nil || b == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return a.OwnerName == b.OwnerName && a.OwnerIsGroup == b.OwnerIsGroup
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user