mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Adds a bool flag to `scanIfItemChanged()` to indicate when the scan was initiated from a delete function, and if so, tell `IsEquivalentOptional()` to ignore Xattrs and Ownership regardless of the global setting. I tested this with my sledgehammer and it seems to pass.
This commit is contained in:
parent
07a9fa2dbd
commit
bbd2a7fbc5
@ -596,7 +596,7 @@ func (f *sendReceiveFolder) handleDir(file protocol.FileInfo, snap *db.Snapshot,
|
|||||||
case err == nil && !info.IsDir():
|
case err == nil && !info.IsDir():
|
||||||
// Check that it is what we have in the database.
|
// Check that it is what we have in the database.
|
||||||
curFile, hasCurFile := snap.Get(protocol.LocalDeviceID, file.Name)
|
curFile, hasCurFile := snap.Get(protocol.LocalDeviceID, file.Name)
|
||||||
if err := f.scanIfItemChanged(file.Name, info, curFile, hasCurFile, scanChan); err != nil {
|
if err := f.scanIfItemChanged(file.Name, info, curFile, hasCurFile, false, scanChan); err != nil {
|
||||||
f.newPullError(file.Name, fmt.Errorf("handling dir: %w", err))
|
f.newPullError(file.Name, fmt.Errorf("handling dir: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ func (f *sendReceiveFolder) handleSymlinkCheckExisting(file protocol.FileInfo, s
|
|||||||
}
|
}
|
||||||
// Check that it is what we have in the database.
|
// Check that it is what we have in the database.
|
||||||
curFile, hasCurFile := snap.Get(protocol.LocalDeviceID, file.Name)
|
curFile, hasCurFile := snap.Get(protocol.LocalDeviceID, file.Name)
|
||||||
if err := f.scanIfItemChanged(file.Name, info, curFile, hasCurFile, scanChan); err != nil {
|
if err := f.scanIfItemChanged(file.Name, info, curFile, hasCurFile, false, scanChan); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Remove it to replace with the symlink. This also handles the
|
// Remove it to replace with the symlink. This also handles the
|
||||||
@ -1629,7 +1629,7 @@ func (f *sendReceiveFolder) performFinish(file, curFile protocol.FileInfo, hasCu
|
|||||||
// There is an old file or directory already in place. We need to
|
// There is an old file or directory already in place. We need to
|
||||||
// handle that.
|
// handle that.
|
||||||
|
|
||||||
if err := f.scanIfItemChanged(file.Name, stat, curFile, hasCurFile, scanChan); err != nil {
|
if err := f.scanIfItemChanged(file.Name, stat, curFile, hasCurFile, false, scanChan); err != nil {
|
||||||
return fmt.Errorf("checking existing file: %w", err)
|
return fmt.Errorf("checking existing file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1967,7 +1967,6 @@ func (f *sendReceiveFolder) deleteDirOnDiskHandleChildren(dir string, snap *db.S
|
|||||||
var dirsToDelete []string
|
var dirsToDelete []string
|
||||||
var hasIgnored, hasKnown, hasToBeScanned, hasReceiveOnlyChanged bool
|
var hasIgnored, hasKnown, hasToBeScanned, hasReceiveOnlyChanged bool
|
||||||
var delErr error
|
var delErr error
|
||||||
|
|
||||||
err := f.mtimefs.Walk(dir, func(path string, info fs.FileInfo, err error) error {
|
err := f.mtimefs.Walk(dir, func(path string, info fs.FileInfo, err error) error {
|
||||||
if path == dir {
|
if path == dir {
|
||||||
return nil
|
return nil
|
||||||
@ -2066,7 +2065,7 @@ func (f *sendReceiveFolder) deleteDirOnDiskHandleChildren(dir string, snap *db.S
|
|||||||
// scanIfItemChanged schedules the given file for scanning and returns errModified
|
// scanIfItemChanged schedules the given file for scanning and returns errModified
|
||||||
// if it differs from the information in the database. Returns nil if the file has
|
// if it differs from the information in the database. Returns nil if the file has
|
||||||
// not changed.
|
// not changed.
|
||||||
func (f *sendReceiveFolder) scanIfItemChanged(name string, stat fs.FileInfo, item protocol.FileInfo, hasItem bool, scanChan chan<- string) (err error) {
|
func (f *sendReceiveFolder) scanIfItemChanged(name string, stat fs.FileInfo, item protocol.FileInfo, hasItem bool, fromDelete bool, scanChan chan<- string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == errModified {
|
if err == errModified {
|
||||||
scanChan <- name
|
scanChan <- name
|
||||||
@ -2086,14 +2085,13 @@ func (f *sendReceiveFolder) scanIfItemChanged(name string, stat fs.FileInfo, ite
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("comparing item on disk to db: %w", err)
|
return fmt.Errorf("comparing item on disk to db: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !statItem.IsEquivalentOptional(item, protocol.FileInfoComparison{
|
if !statItem.IsEquivalentOptional(item, protocol.FileInfoComparison{
|
||||||
ModTimeWindow: f.modTimeWindow,
|
ModTimeWindow: f.modTimeWindow,
|
||||||
IgnorePerms: f.IgnorePerms,
|
IgnorePerms: f.IgnorePerms,
|
||||||
IgnoreBlocks: true,
|
IgnoreBlocks: true,
|
||||||
IgnoreFlags: protocol.LocalAllFlags,
|
IgnoreFlags: protocol.LocalAllFlags,
|
||||||
IgnoreOwnership: !f.SyncOwnership,
|
IgnoreOwnership: fromDelete || !f.SyncOwnership,
|
||||||
IgnoreXattrs: !f.SyncXattrs,
|
IgnoreXattrs: fromDelete || !f.SyncXattrs,
|
||||||
}) {
|
}) {
|
||||||
return errModified
|
return errModified
|
||||||
}
|
}
|
||||||
@ -2124,7 +2122,7 @@ func (f *sendReceiveFolder) checkToBeDeleted(file, cur protocol.FileInfo, hasCur
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.scanIfItemChanged(file.Name, stat, cur, hasCur, scanChan)
|
return f.scanIfItemChanged(file.Name, stat, cur, hasCur, true, scanChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setPlatformData makes adjustments to the metadata that should happen for
|
// setPlatformData makes adjustments to the metadata that should happen for
|
||||||
|
Loading…
Reference in New Issue
Block a user