+13
-11
@@ -44,11 +44,12 @@ type folder struct {
|
||||
|
||||
localFlags uint32
|
||||
|
||||
model *model
|
||||
shortID protocol.ShortID
|
||||
fset *db.FileSet
|
||||
ignores *ignore.Matcher
|
||||
ctx context.Context
|
||||
model *model
|
||||
shortID protocol.ShortID
|
||||
fset *db.FileSet
|
||||
ignores *ignore.Matcher
|
||||
modTimeWindow time.Duration
|
||||
ctx context.Context
|
||||
|
||||
scanInterval time.Duration
|
||||
scanTimer *time.Timer
|
||||
@@ -95,10 +96,11 @@ func newFolder(model *model, fset *db.FileSet, ignores *ignore.Matcher, cfg conf
|
||||
FolderStatisticsReference: stats.NewFolderStatisticsReference(model.db, cfg.ID),
|
||||
ioLimiter: ioLimiter,
|
||||
|
||||
model: model,
|
||||
shortID: model.shortID,
|
||||
fset: fset,
|
||||
ignores: ignores,
|
||||
model: model,
|
||||
shortID: model.shortID,
|
||||
fset: fset,
|
||||
ignores: ignores,
|
||||
modTimeWindow: cfg.ModTimeWindow(),
|
||||
|
||||
scanInterval: time.Duration(cfg.RescanIntervalS) * time.Second,
|
||||
scanTimer: time.NewTimer(0), // The first scan should be done immediately.
|
||||
@@ -457,7 +459,7 @@ func (f *folder) scanSubdirs(subDirs []string) error {
|
||||
ShortID: f.shortID,
|
||||
ProgressTickIntervalS: f.ScanProgressIntervalS,
|
||||
LocalFlags: f.localFlags,
|
||||
ModTimeWindow: f.ModTimeWindow(),
|
||||
ModTimeWindow: f.modTimeWindow,
|
||||
EventLogger: f.evLogger,
|
||||
})
|
||||
|
||||
@@ -480,7 +482,7 @@ func (f *folder) scanSubdirs(subDirs []string) error {
|
||||
batchAppend = func(fi protocol.FileInfo, snap *db.Snapshot) {
|
||||
switch gf, ok := snap.GetGlobal(fi.Name); {
|
||||
case !ok:
|
||||
case gf.IsEquivalentOptional(fi, f.ModTimeWindow(), false, false, protocol.FlagLocalReceiveOnly):
|
||||
case gf.IsEquivalentOptional(fi, f.modTimeWindow, false, false, protocol.FlagLocalReceiveOnly):
|
||||
// What we have locally is equivalent to the global file.
|
||||
fi.Version = fi.Version.Merge(gf.Version)
|
||||
fallthrough
|
||||
|
||||
@@ -77,7 +77,7 @@ func (f *sendOnlyFolder) pull() bool {
|
||||
}
|
||||
|
||||
file := intf.(protocol.FileInfo)
|
||||
if !file.IsEquivalentOptional(curFile, f.ModTimeWindow(), f.IgnorePerms, false, 0) {
|
||||
if !file.IsEquivalentOptional(curFile, f.modTimeWindow, f.IgnorePerms, false, 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -420,17 +420,17 @@ func (f *sendReceiveFolder) processNeeded(snap *db.Snapshot, dbUpdateChan chan<-
|
||||
// Now do the file queue. Reorder it according to configuration.
|
||||
|
||||
switch f.Order {
|
||||
case config.OrderRandom:
|
||||
case config.PullOrderRandom:
|
||||
f.queue.Shuffle()
|
||||
case config.OrderAlphabetic:
|
||||
case config.PullOrderAlphabetic:
|
||||
// The queue is already in alphabetic order.
|
||||
case config.OrderSmallestFirst:
|
||||
case config.PullOrderSmallestFirst:
|
||||
f.queue.SortSmallestFirst()
|
||||
case config.OrderLargestFirst:
|
||||
case config.PullOrderLargestFirst:
|
||||
f.queue.SortLargestFirst()
|
||||
case config.OrderOldestFirst:
|
||||
case config.PullOrderOldestFirst:
|
||||
f.queue.SortOldestFirst()
|
||||
case config.OrderNewestFirst:
|
||||
case config.PullOrderNewestFirst:
|
||||
f.queue.SortNewestFirst()
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ func (f *sendReceiveFolder) handleDir(file protocol.FileInfo, snap *db.Snapshot,
|
||||
// don't handle modification times on directories, because that sucks...)
|
||||
// It's OK to change mode bits on stuff within non-writable directories.
|
||||
if !f.IgnorePerms && !file.NoPermissions {
|
||||
if err := f.fs.Chmod(file.Name, mode|(fs.FileMode(info.Mode())&retainBits)); err != nil {
|
||||
if err := f.fs.Chmod(file.Name, mode|(info.Mode()&retainBits)); err != nil {
|
||||
f.newPullError(file.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -962,7 +962,7 @@ func (f *sendReceiveFolder) renameFile(cur, source, target protocol.FileInfo, sn
|
||||
default:
|
||||
var fi protocol.FileInfo
|
||||
if fi, err = scanner.CreateFileInfo(stat, target.Name, f.fs); err == nil {
|
||||
if !fi.IsEquivalentOptional(curTarget, f.ModTimeWindow(), f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
if !fi.IsEquivalentOptional(curTarget, f.modTimeWindow, f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
// Target changed
|
||||
scanChan <- target.Name
|
||||
err = errModified
|
||||
@@ -1874,7 +1874,7 @@ func (f *sendReceiveFolder) deleteDirOnDisk(dir string, snap *db.Snapshot, scanC
|
||||
hasToBeScanned = true
|
||||
continue
|
||||
}
|
||||
if !cf.IsEquivalentOptional(diskFile, f.ModTimeWindow(), f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
if !cf.IsEquivalentOptional(diskFile, f.modTimeWindow, f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
// File on disk changed compared to what we have in db
|
||||
// -> schedule scan.
|
||||
scanChan <- fullDirFile
|
||||
@@ -1946,7 +1946,7 @@ func (f *sendReceiveFolder) scanIfItemChanged(name string, stat fs.FileInfo, ite
|
||||
return errors.Wrap(err, "comparing item on disk to db")
|
||||
}
|
||||
|
||||
if !statItem.IsEquivalentOptional(item, f.ModTimeWindow(), f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
if !statItem.IsEquivalentOptional(item, f.modTimeWindow, f.IgnorePerms, true, protocol.LocalAllFlags) {
|
||||
return errModified
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -1781,7 +1781,10 @@ func (m *model) OnHello(remoteID protocol.DeviceID, addr net.Addr, hello protoco
|
||||
func (m *model) GetHello(id protocol.DeviceID) protocol.HelloIntf {
|
||||
name := ""
|
||||
if _, ok := m.cfg.Device(id); ok {
|
||||
name = m.cfg.MyName()
|
||||
// Set our name (from the config of our device ID) only if we already know about the other side device ID.
|
||||
if myCfg, ok := m.cfg.Device(m.id); ok {
|
||||
name = myCfg.Name
|
||||
}
|
||||
}
|
||||
return &protocol.Hello{
|
||||
DeviceName: name,
|
||||
|
||||
@@ -340,7 +340,7 @@ func TestDeviceRename(t *testing.T) {
|
||||
t.Errorf("Device name got overwritten")
|
||||
}
|
||||
|
||||
cfgw, err := config.Load("testdata/tmpconfig.xml", myID, events.NoopLogger)
|
||||
cfgw, _, err := config.Load("testdata/tmpconfig.xml", myID, events.NoopLogger)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user