lib: Get rid of buggy filesystem wrapping (#8257)

This commit is contained in:
Simon Frei
2022-04-10 20:55:05 +02:00
committed by GitHub
parent 9b09bcc5f1
commit db72579f0e
26 changed files with 226 additions and 189 deletions
+2 -2
View File
@@ -108,7 +108,7 @@ func newFolder(model *model, fset *db.FileSet, ignores *ignore.Matcher, cfg conf
shortID: model.shortID,
fset: fset,
ignores: ignores,
mtimefs: fset.MtimeFS(cfg.Filesystem()),
mtimefs: cfg.Filesystem(fset),
modTimeWindow: cfg.ModTimeWindow(),
done: make(chan struct{}),
@@ -1001,7 +1001,7 @@ func (f *folder) monitorWatch(ctx context.Context) {
for {
select {
case <-failTimer.C:
eventChan, errChan, err = f.Filesystem().Watch(".", f.ignores, ctx, f.IgnorePerms)
eventChan, errChan, err = f.mtimefs.Watch(".", f.ignores, ctx, f.IgnorePerms)
// We do this once per minute initially increased to
// max one hour in case of repeat failures.
f.scanOnWatchErr()
+6 -6
View File
@@ -28,7 +28,7 @@ func TestRecvOnlyRevertDeletes(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
@@ -110,7 +110,7 @@ func TestRecvOnlyRevertNeeds(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
@@ -200,7 +200,7 @@ func TestRecvOnlyUndoChanges(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
@@ -270,7 +270,7 @@ func TestRecvOnlyDeletedRemoteDrop(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
@@ -335,7 +335,7 @@ func TestRecvOnlyRemoteUndoChanges(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
@@ -425,7 +425,7 @@ func TestRecvOnlyRevertOwnID(t *testing.T) {
m, f, wcfgCancel := setupROFolder(t)
defer wcfgCancel()
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
defer cleanupModel(m)
addFakeConn(m, device1, f.ID)
+1 -1
View File
@@ -1264,7 +1264,7 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch
// Hope that it's usually in the same folder, so start with that one.
folders := []string{f.folderID}
for folder, cfg := range f.model.cfg.Folders() {
folderFilesystems[folder] = cfg.Filesystem()
folderFilesystems[folder] = cfg.Filesystem(nil)
if folder != f.folderID {
folders = append(folders, folder)
}
+14 -14
View File
@@ -109,7 +109,7 @@ func setupSendReceiveFolder(t testing.TB, files ...protocol.FileInfo) (*testMode
func cleanupSRFolder(f *sendReceiveFolder, m *testModel, wrapperCancel context.CancelFunc) {
wrapperCancel()
os.Remove(m.cfg.ConfigPath())
os.RemoveAll(f.Filesystem().URI())
os.RemoveAll(f.Filesystem(nil).URI())
}
// Layout of the files: (indexes from the above array)
@@ -172,7 +172,7 @@ func TestHandleFileWithTemp(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t, existingFile)
defer cleanupSRFolder(f, m, wcfgCancel)
if _, err := prepareTmpFile(f.Filesystem()); err != nil {
if _, err := prepareTmpFile(f.Filesystem(nil)); err != nil {
t.Fatal(err)
}
@@ -230,7 +230,7 @@ func TestCopierFinder(t *testing.T) {
defer cleanupSRFolder(f, m, wcfgCancel)
if _, err := prepareTmpFile(f.Filesystem()); err != nil {
if _, err := prepareTmpFile(f.Filesystem(nil)); err != nil {
t.Fatal(err)
}
@@ -290,7 +290,7 @@ func TestCopierFinder(t *testing.T) {
}
// Verify that the fetched blocks have actually been written to the temp file
blks, err := scanner.HashFile(context.TODO(), f.Filesystem(), tempFile, protocol.MinBlockSize, nil, false)
blks, err := scanner.HashFile(context.TODO(), f.Filesystem(nil), tempFile, protocol.MinBlockSize, nil, false)
if err != nil {
t.Log(err)
}
@@ -308,7 +308,7 @@ func TestWeakHash(t *testing.T) {
// Setup the model/pull environment
model, fo, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(fo, model, wcfgCancel)
ffs := fo.Filesystem()
ffs := fo.Filesystem(nil)
tempFile := fs.TempName("weakhash")
var shift int64 = 10
@@ -673,7 +673,7 @@ func TestDeregisterOnFailInPull(t *testing.T) {
func TestIssue3164(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
tmpDir := ffs.URI()
ignDir := filepath.Join("issue3164", "oktodelete")
@@ -764,7 +764,7 @@ func TestDiffEmpty(t *testing.T) {
func TestDeleteIgnorePerms(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
f.IgnorePerms = true
name := "deleteIgnorePerms"
@@ -806,7 +806,7 @@ func TestCopyOwner(t *testing.T) {
f.folder.FolderConfiguration.CopyOwnershipFromParent = true
f.fset = newFileSet(t, f.ID, m.db)
f.mtimefs = f.fset.MtimeFS(f.Filesystem())
f.mtimefs = f.Filesystem(f.fset)
// Create a parent dir with a certain owner/group.
@@ -905,7 +905,7 @@ func TestCopyOwner(t *testing.T) {
func TestSRConflictReplaceFileByDir(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
name := "foo"
@@ -937,7 +937,7 @@ func TestSRConflictReplaceFileByDir(t *testing.T) {
func TestSRConflictReplaceFileByLink(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
name := "foo"
@@ -970,7 +970,7 @@ func TestSRConflictReplaceFileByLink(t *testing.T) {
func TestDeleteBehindSymlink(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
destDir := createTmpDir()
defer os.RemoveAll(destDir)
@@ -1063,7 +1063,7 @@ func TestPullCtxCancel(t *testing.T) {
func TestPullDeleteUnscannedDir(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
dir := "foobar"
must(t, ffs.MkdirAll(dir, 0777))
@@ -1092,7 +1092,7 @@ func TestPullDeleteUnscannedDir(t *testing.T) {
func TestPullCaseOnlyPerformFinish(t *testing.T) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
name := "foo"
contents := []byte("contents")
@@ -1153,7 +1153,7 @@ func TestPullCaseOnlySymlink(t *testing.T) {
func testPullCaseOnlyDirOrSymlink(t *testing.T, dir bool) {
m, f, wcfgCancel := setupSendReceiveFolder(t)
defer cleanupSRFolder(f, m, wcfgCancel)
ffs := f.Filesystem()
ffs := f.Filesystem(nil)
name := "foo"
if dir {
+10 -10
View File
@@ -332,7 +332,7 @@ func (m *model) StartDeadlockDetector(timeout time.Duration) {
// Need to hold lock on m.fmut when calling this.
func (m *model) addAndStartFolderLocked(cfg config.FolderConfiguration, fset *db.FileSet, cacheIgnoredFiles bool) {
ignores := ignore.New(cfg.Filesystem(), ignore.WithCache(cacheIgnoredFiles))
ignores := ignore.New(cfg.Filesystem(nil), ignore.WithCache(cacheIgnoredFiles))
if cfg.Type != config.FolderTypeReceiveEncrypted {
if err := ignores.Load(".stignore"); err != nil && !fs.IsNotExist(err) {
l.Warnln("Loading ignores:", err)
@@ -396,7 +396,7 @@ func (m *model) addAndStartFolderLockedWithIgnores(cfg config.FolderConfiguratio
}
// These are our metadata files, and they should always be hidden.
ffs := cfg.Filesystem()
ffs := cfg.Filesystem(nil)
_ = ffs.Hide(config.DefaultMarkerName)
_ = ffs.Hide(".stversions")
_ = ffs.Hide(".stignore")
@@ -428,7 +428,7 @@ func (m *model) warnAboutOverwritingProtectedFiles(cfg config.FolderConfiguratio
}
// This is a bit of a hack.
ffs := cfg.Filesystem()
ffs := cfg.Filesystem(nil)
if ffs.Type() != fs.FilesystemTypeBasic {
return
}
@@ -478,7 +478,7 @@ func (m *model) removeFolder(cfg config.FolderConfiguration) {
if isPathUnique {
// Remove (if empty and removable) or move away (if non-empty or
// otherwise not removable) Syncthing-specific marker files.
fs := cfg.Filesystem()
fs := cfg.Filesystem(nil)
if err := fs.Remove(config.DefaultMarkerName); err != nil {
moved := config.DefaultMarkerName + time.Now().Format(".removed-20060102-150405")
_ = fs.Rename(config.DefaultMarkerName, moved)
@@ -1839,7 +1839,7 @@ func (m *model) Request(deviceID protocol.DeviceID, folder, name string, blockNo
// Grab the FS after limiting, as it causes I/O and we want to minimize
// the race time between the symlink check and the read.
folderFs := folderCfg.Filesystem()
folderFs := folderCfg.Filesystem(nil)
if err := osutil.TraversesSymlink(folderFs, filepath.Dir(name)); err != nil {
l.Debugf("%v REQ(in) traversal check: %s - %s: %q / %q o=%d s=%d", m, err, deviceID, folder, name, offset, size)
@@ -2005,7 +2005,7 @@ func (m *model) GetMtimeMapping(folder string, file string) (fs.MtimeMapping, er
if !ok {
return fs.MtimeMapping{}, ErrFolderMissing
}
return fs.GetMtimeMapping(ffs.MtimeFS(fcfg.Filesystem()), file)
return fs.GetMtimeMapping(fcfg.Filesystem(ffs), file)
}
// Connection returns the current connection for device, and a boolean whether a connection was found.
@@ -2039,7 +2039,7 @@ func (m *model) LoadIgnores(folder string) ([]string, []string, error) {
}
if !ignoresOk {
ignores = ignore.New(cfg.Filesystem())
ignores = ignore.New(cfg.Filesystem(nil))
}
err := ignores.Load(".stignore")
@@ -2094,7 +2094,7 @@ func (m *model) setIgnores(cfg config.FolderConfiguration, content []string) err
return err
}
if err := ignore.WriteIgnores(cfg.Filesystem(), ".stignore", content); err != nil {
if err := ignore.WriteIgnores(cfg.Filesystem(nil), ".stignore", content); err != nil {
l.Warnln("Saving .stignore:", err)
return err
}
@@ -3207,7 +3207,7 @@ type storedEncryptionToken struct {
}
func readEncryptionToken(cfg config.FolderConfiguration) ([]byte, error) {
fd, err := cfg.Filesystem().Open(encryptionTokenPath(cfg))
fd, err := cfg.Filesystem(nil).Open(encryptionTokenPath(cfg))
if err != nil {
return nil, err
}
@@ -3221,7 +3221,7 @@ func readEncryptionToken(cfg config.FolderConfiguration) ([]byte, error) {
func writeEncryptionToken(token []byte, cfg config.FolderConfiguration) error {
tokenName := encryptionTokenPath(cfg)
fd, err := cfg.Filesystem().OpenFile(tokenName, fs.OptReadWrite|fs.OptCreate, 0666)
fd, err := cfg.Filesystem(nil).OpenFile(tokenName, fs.OptReadWrite|fs.OptCreate, 0666)
if err != nil {
return err
}
+28 -28
View File
@@ -222,7 +222,7 @@ func BenchmarkIndex_100(b *testing.B) {
func benchmarkIndex(b *testing.B, nfiles int) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(b)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
files := genFiles(nfiles)
must(b, m.Index(device1, fcfg.ID, files))
@@ -249,7 +249,7 @@ func BenchmarkIndexUpdate_10000_1(b *testing.B) {
func benchmarkIndexUpdate(b *testing.B, nfiles, nufiles int) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(b)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
files := genFiles(nfiles)
ufiles := genFiles(nufiles)
@@ -1517,7 +1517,7 @@ func TestIgnores(t *testing.T) {
// Invalid path, treated like no patterns at all.
fcfg := config.FolderConfiguration{ID: "fresh", Path: "XXX"}
ignores := ignore.New(fcfg.Filesystem(), ignore.WithCache(m.cfg.Options().CacheIgnoredFiles))
ignores := ignore.New(fcfg.Filesystem(nil), ignore.WithCache(m.cfg.Options().CacheIgnoredFiles))
m.fmut.Lock()
m.folderCfgs[fcfg.ID] = fcfg
m.folderIgnores[fcfg.ID] = ignores
@@ -1709,7 +1709,7 @@ func TestRWScanRecovery(t *testing.T) {
func TestGlobalDirectoryTree(t *testing.T) {
m, _, fcfg, wCancel := setupModelWithConnection(t)
defer wCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
b := func(isfile bool, path ...string) protocol.FileInfo {
typ := protocol.FileInfoTypeDirectory
@@ -2012,7 +2012,7 @@ func BenchmarkTree_100_10(b *testing.B) {
func benchmarkTree(b *testing.B, n1, n2 int) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(b)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
m.ScanFolder(fcfg.ID)
files := genDeepFiles(n1, n2)
@@ -2477,7 +2477,7 @@ func TestIssue2571(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
testFs := fcfg.Filesystem()
testFs := fcfg.Filesystem(nil)
defer os.RemoveAll(testFs.URI())
for _, dir := range []string{"toLink", "linkTarget"} {
@@ -2516,7 +2516,7 @@ func TestIssue4573(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
testFs := fcfg.Filesystem()
testFs := fcfg.Filesystem(nil)
defer os.RemoveAll(testFs.URI())
must(t, testFs.MkdirAll("inaccessible", 0755))
@@ -2546,7 +2546,7 @@ func TestIssue4573(t *testing.T) {
func TestInternalScan(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
testFs := fcfg.Filesystem()
testFs := fcfg.Filesystem(nil)
defer os.RemoveAll(testFs.URI())
testCases := map[string]func(protocol.FileInfo) bool{
@@ -2644,7 +2644,7 @@ func TestCustomMarkerName(t *testing.T) {
func TestRemoveDirWithContent(t *testing.T) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
tfs.MkdirAll("dirwith", 0755)
@@ -2706,7 +2706,7 @@ func TestIssue4475(t *testing.T) {
m, conn, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModel(m)
testFs := fcfg.Filesystem()
testFs := fcfg.Filesystem(nil)
// Scenario: Dir is deleted locally and before syncing/index exchange
// happens, a file is create in that dir on the remote.
@@ -2769,7 +2769,7 @@ func TestVersionRestore(t *testing.T) {
fcfg := newFolderConfiguration(defaultCfgWrapper, "default", "default", fs.FilesystemTypeBasic, dir)
fcfg.Versioning.Type = "simple"
fcfg.FSWatcherEnabled = false
filesystem := fcfg.Filesystem()
filesystem := fcfg.Filesystem(nil)
rawConfig := config.Configuration{
Folders: []config.FolderConfiguration{fcfg},
@@ -3005,7 +3005,7 @@ func TestIssue4094(t *testing.T) {
t.Fatalf("failed setting ignores: %v", err)
}
if _, err := fcfg.Filesystem().Lstat(".stignore"); err != nil {
if _, err := fcfg.Filesystem(nil).Lstat(".stignore"); err != nil {
t.Fatalf("failed stating .stignore: %v", err)
}
}
@@ -3037,7 +3037,7 @@ func TestIssue4903(t *testing.T) {
t.Fatalf("expected path missing error, got: %v", err)
}
if _, err := fcfg.Filesystem().Lstat("."); !fs.IsNotExist(err) {
if _, err := fcfg.Filesystem(nil).Lstat("."); !fs.IsNotExist(err) {
t.Fatalf("Expected missing path error, got: %v", err)
}
}
@@ -3067,7 +3067,7 @@ func TestParentOfUnignored(t *testing.T) {
m, cancel := newState(t, defaultCfg)
defer cleanupModel(m)
defer cancel()
defer defaultFolderConfig.Filesystem().Remove(".stignore")
defer defaultFolderConfig.Filesystem(nil).Remove(".stignore")
m.SetIgnores("default", []string{"!quux", "*"})
@@ -3184,7 +3184,7 @@ func TestConnCloseOnRestart(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
m := setupModel(t, w)
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
br := &testutils.BlockingRW{}
nw := &testutils.NoopRW{}
@@ -3220,7 +3220,7 @@ func TestConnCloseOnRestart(t *testing.T) {
func TestModTimeWindow(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
fcfg.RawModTimeWindowS = 2
setFolder(t, w, fcfg)
m := setupModel(t, w)
@@ -3277,7 +3277,7 @@ func TestModTimeWindow(t *testing.T) {
func TestDevicePause(t *testing.T) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
sub := m.evLogger.Subscribe(events.DevicePaused)
defer sub.Unsubscribe()
@@ -3304,7 +3304,7 @@ func TestDevicePause(t *testing.T) {
func TestDeviceWasSeen(t *testing.T) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
m.deviceWasSeen(device1)
@@ -3399,7 +3399,7 @@ func TestRenameSequenceOrder(t *testing.T) {
numFiles := 20
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
for i := 0; i < numFiles; i++ {
v := fmt.Sprintf("%d", i)
writeFile(t, ffs, v, []byte(v))
@@ -3468,7 +3468,7 @@ func TestRenameSameFile(t *testing.T) {
m := setupModel(t, wcfg)
defer cleanupModel(m)
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
writeFile(t, ffs, "file", []byte("file"))
m.ScanFolders()
@@ -3519,7 +3519,7 @@ func TestRenameEmptyFile(t *testing.T) {
m := setupModel(t, wcfg)
defer cleanupModel(m)
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
writeFile(t, ffs, "file", []byte("data"))
writeFile(t, ffs, "empty", nil)
@@ -3596,7 +3596,7 @@ func TestBlockListMap(t *testing.T) {
m := setupModel(t, wcfg)
defer cleanupModel(m)
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
writeFile(t, ffs, "one", []byte("content"))
writeFile(t, ffs, "two", []byte("content"))
writeFile(t, ffs, "three", []byte("content"))
@@ -3664,7 +3664,7 @@ func TestScanRenameCaseOnly(t *testing.T) {
m := setupModel(t, wcfg)
defer cleanupModel(m)
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
name := "foo"
writeFile(t, ffs, name, []byte("contents"))
@@ -3782,7 +3782,7 @@ func TestAddFolderCompletion(t *testing.T) {
func TestScanDeletedROChangedOnSR(t *testing.T) {
m, _, fcfg, wCancel := setupModelWithConnection(t)
ffs := fcfg.Filesystem()
ffs := fcfg.Filesystem(nil)
defer wCancel()
defer cleanupModelAndRemoveDir(m, ffs.URI())
fcfg.Type = config.FolderTypeReceiveOnly
@@ -3886,7 +3886,7 @@ func testConfigChangeTriggersClusterConfigs(t *testing.T, expectFirst, expectSec
func TestIssue6961(t *testing.T) {
wcfg, fcfg, wcfgCancel := tmpDefaultWrapper()
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
waiter, err := wcfg.Modify(func(cfg *config.Configuration) {
cfg.SetDevice(newDeviceConfiguration(cfg.Defaults.Device, device2, "device2"))
fcfg.Type = config.FolderTypeReceiveOnly
@@ -3956,7 +3956,7 @@ func TestIssue6961(t *testing.T) {
func TestCompletionEmptyGlobal(t *testing.T) {
m, _, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID.Short()), Sequence: 1}}
m.fmut.Lock()
m.folderFiles[fcfg.ID].Update(protocol.LocalDeviceID, files)
@@ -4157,7 +4157,7 @@ func TestCCFolderNotRunning(t *testing.T) {
// Create the folder, but don't start it.
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
m := newModel(t, w, myID, "syncthing", "dev", nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
@@ -4264,7 +4264,7 @@ func TestDeletedNotLocallyChangedReceiveEncrypted(t *testing.T) {
func deletedNotLocallyChanged(t *testing.T, ft config.FolderType) {
w, fcfg, wCancel := tmpDefaultWrapper()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
fcfg.Type = ft
setFolder(t, w, fcfg)
defer wCancel()
+20 -20
View File
@@ -32,7 +32,7 @@ func TestRequestSimple(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
// We listen for incoming index updates and trigger when we see one for
@@ -79,7 +79,7 @@ func TestSymlinkTraversalRead(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
// We listen for incoming index updates and trigger when we see one for
// the expected test file.
@@ -122,7 +122,7 @@ func TestSymlinkTraversalWrite(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
// We listen for incoming index updates and trigger when we see one for
// the expected names.
@@ -181,7 +181,7 @@ func TestRequestCreateTmpSymlink(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
// We listen for incoming index updates and trigger when we see one for
// the expected test file.
@@ -224,7 +224,7 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
defer func() {
os.RemoveAll(fcfg.Filesystem().URI())
os.RemoveAll(fcfg.Filesystem(nil).URI())
os.Remove(w.ConfigPath())
}()
@@ -301,7 +301,7 @@ func pullInvalidIgnored(t *testing.T, ft config.FolderType) {
w, wCancel := createTmpWrapper(defaultCfgWrapper.RawCopy())
defer wCancel()
fcfg := testFolderConfigTmp()
fss := fcfg.Filesystem()
fss := fcfg.Filesystem(nil)
fcfg.Type = ft
setFolder(t, w, fcfg)
m := setupModel(t, w)
@@ -430,7 +430,7 @@ func pullInvalidIgnored(t *testing.T, ft config.FolderType) {
func TestIssue4841(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
received := make(chan []protocol.FileInfo)
fc.setIndexFn(func(_ context.Context, _ string, fs []protocol.FileInfo) error {
@@ -478,7 +478,7 @@ func TestIssue4841(t *testing.T) {
func TestRescanIfHaveInvalidContent(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
payload := []byte("hello")
@@ -544,7 +544,7 @@ func TestRescanIfHaveInvalidContent(t *testing.T) {
func TestParentDeletion(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
testFs := fcfg.Filesystem()
testFs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, testFs.URI())
parent := "foo"
@@ -623,7 +623,7 @@ func TestRequestSymlinkWindows(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem(nil).URI())
received := make(chan []protocol.FileInfo)
fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error {
@@ -691,7 +691,7 @@ func equalContents(path string, contents []byte) error {
func TestRequestRemoteRenameChanged(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
tmpDir := tfs.URI()
defer cleanupModelAndRemoveDir(m, tfs.URI())
@@ -825,7 +825,7 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
func TestRequestRemoteRenameConflict(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
tmpDir := tfs.URI()
defer cleanupModelAndRemoveDir(m, tmpDir)
@@ -916,7 +916,7 @@ func TestRequestRemoteRenameConflict(t *testing.T) {
func TestRequestDeleteChanged(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
done := make(chan struct{})
@@ -984,7 +984,7 @@ func TestRequestDeleteChanged(t *testing.T) {
func TestNeedFolderFiles(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
tmpDir := tfs.URI()
defer cleanupModelAndRemoveDir(m, tmpDir)
@@ -1032,7 +1032,7 @@ func TestIgnoreDeleteUnignore(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
m := setupModel(t, w)
fss := fcfg.Filesystem()
fss := fcfg.Filesystem(nil)
tmpDir := fss.URI()
defer cleanupModelAndRemoveDir(m, tmpDir)
@@ -1127,7 +1127,7 @@ func TestIgnoreDeleteUnignore(t *testing.T) {
func TestRequestLastFileProgress(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
done := make(chan struct{})
@@ -1162,7 +1162,7 @@ func TestRequestIndexSenderPause(t *testing.T) {
m, fc, fcfg, wcfgCancel := setupModelWithConnection(t)
defer wcfgCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
indexChan := make(chan []protocol.FileInfo)
@@ -1275,7 +1275,7 @@ func TestRequestIndexSenderPause(t *testing.T) {
func TestRequestIndexSenderClusterConfigBeforeStart(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
dir1 := "foo"
dir2 := "bar"
@@ -1342,7 +1342,7 @@ func TestRequestReceiveEncrypted(t *testing.T) {
w, fcfg, wCancel := tmpDefaultWrapper()
defer wCancel()
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
fcfg.Type = config.FolderTypeReceiveEncrypted
setFolder(t, w, fcfg)
@@ -1450,7 +1450,7 @@ func TestRequestGlobalInvalidToValid(t *testing.T) {
must(t, err)
waiter.Wait()
addFakeConn(m, device2, fcfg.ID)
tfs := fcfg.Filesystem()
tfs := fcfg.Filesystem(nil)
defer cleanupModelAndRemoveDir(m, tfs.URI())
indexChan := make(chan []protocol.FileInfo, 1)
+2 -2
View File
@@ -40,7 +40,7 @@ func init() {
defaultCfgWrapper, defaultCfgWrapperCancel = createTmpWrapper(config.New(myID))
defaultFolderConfig = testFolderConfig("testdata")
defaultFs = defaultFolderConfig.Filesystem()
defaultFs = defaultFolderConfig.Filesystem(nil)
waiter, _ := defaultCfgWrapper.Modify(func(cfg *config.Configuration) {
cfg.SetDevice(newDeviceConfiguration(cfg.Defaults.Device, device1, "device1"))
@@ -308,7 +308,7 @@ func folderIgnoresAlwaysReload(t testing.TB, m *testModel, fcfg config.FolderCon
t.Helper()
m.removeFolder(fcfg)
fset := newFileSet(t, fcfg.ID, m.db)
ignores := ignore.New(fcfg.Filesystem(), ignore.WithCache(true), ignore.WithChangeDetector(newAlwaysChanged()))
ignores := ignore.New(fcfg.Filesystem(nil), ignore.WithCache(true), ignore.WithChangeDetector(newAlwaysChanged()))
m.fmut.Lock()
m.addAndStartFolderLockedWithIgnores(fcfg, fset, ignores)
m.fmut.Unlock()