Unignored files are marked as conflicting while scanning, which is then resolved in the subsequent pull. Automatically reconciles needed items on send-only folders, if they do not actually differ except for internal metadata.
This commit is contained in:
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/d4l3k/messagediff"
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syncthing/syncthing/lib/events"
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
"github.com/syncthing/syncthing/lib/ignore"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
@@ -50,6 +49,7 @@ func init() {
|
||||
defaultFolderConfig = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, "testdata")
|
||||
defaultFolderConfig.Devices = []config.FolderDeviceConfiguration{{DeviceID: device1}}
|
||||
_defaultConfig := config.Configuration{
|
||||
Version: config.CurrentVersion,
|
||||
Folders: []config.FolderConfiguration{defaultFolderConfig},
|
||||
Devices: []config.DeviceConfiguration{config.NewDeviceConfiguration(device1, "device1")},
|
||||
Options: config.OptionsConfiguration{
|
||||
@@ -3442,86 +3442,6 @@ func TestPausedFolders(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullInvalid(t *testing.T) {
|
||||
if runtime.GOOS != "windows" {
|
||||
t.Skip("Windows only")
|
||||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir(".", "_model-")
|
||||
if err != nil {
|
||||
panic("Failed to create temporary testing dir")
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
cfg := defaultConfig.RawCopy()
|
||||
cfg.Folders[0] = config.NewFolderConfiguration(protocol.LocalDeviceID, "default", "default", fs.FilesystemTypeBasic, tmpDir)
|
||||
cfg.Folders[0].Devices = []config.FolderDeviceConfiguration{{DeviceID: device1}}
|
||||
w := config.Wrap("/tmp/cfg", cfg)
|
||||
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(w, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||
m.AddFolder(cfg.Folders[0])
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
defer m.Stop()
|
||||
m.ScanFolder("default")
|
||||
|
||||
if err := m.SetIgnores("default", []string{"*:ignored"}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ign := "invalid:ignored"
|
||||
del := "invalid:deleted"
|
||||
var version protocol.Vector
|
||||
version = version.Update(device1.Short())
|
||||
|
||||
m.IndexUpdate(device1, "default", []protocol.FileInfo{
|
||||
{
|
||||
Name: ign,
|
||||
Size: 1234,
|
||||
Type: protocol.FileInfoTypeFile,
|
||||
Version: version,
|
||||
},
|
||||
{
|
||||
Name: del,
|
||||
Size: 1234,
|
||||
Type: protocol.FileInfoTypeFile,
|
||||
Version: version,
|
||||
Deleted: true,
|
||||
},
|
||||
})
|
||||
|
||||
sub := events.Default.Subscribe(events.FolderErrors)
|
||||
defer events.Default.Unsubscribe(sub)
|
||||
|
||||
timeout := time.NewTimer(5 * time.Second)
|
||||
for {
|
||||
select {
|
||||
case ev := <-sub.C():
|
||||
t.Fatalf("Errors while pulling: %v", ev)
|
||||
case <-timeout.C:
|
||||
t.Fatalf("File wasn't added to index until timeout")
|
||||
default:
|
||||
}
|
||||
|
||||
file, ok := m.CurrentFolderFile("default", ign)
|
||||
if !ok {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
if !file.Invalid {
|
||||
t.Error("Ignored file isn't marked as invalid")
|
||||
}
|
||||
|
||||
if file, ok = m.CurrentFolderFile("default", del); ok {
|
||||
t.Error("Deleted invalid file was added to index")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func addFakeConn(m *Model, dev protocol.DeviceID) *fakeConnection {
|
||||
fc := &fakeConnection{id: dev, model: m}
|
||||
m.AddConnection(fc, protocol.HelloResult{})
|
||||
|
||||
Reference in New Issue
Block a user