|
@@ -17,7 +17,6 @@ import (
|
|
|
|
|
|
"github.com/syncthing/syncthing/lib/db"
|
|
|
"github.com/syncthing/syncthing/lib/fs"
|
|
|
- "github.com/syncthing/syncthing/lib/ignore"
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
|
|
"github.com/syncthing/syncthing/lib/scanner"
|
|
|
"github.com/syncthing/syncthing/lib/sync"
|
|
@@ -27,15 +26,15 @@ func TestMain(m *testing.M) {
|
|
|
// We do this to make sure that the temp file required for the tests
|
|
|
// does not get removed during the tests. Also set the prefix so it's
|
|
|
// found correctly regardless of platform.
|
|
|
- if ignore.TempPrefix != ignore.WindowsTempPrefix {
|
|
|
- originalPrefix := ignore.TempPrefix
|
|
|
- ignore.TempPrefix = ignore.WindowsTempPrefix
|
|
|
+ if fs.TempPrefix != fs.WindowsTempPrefix {
|
|
|
+ originalPrefix := fs.TempPrefix
|
|
|
+ fs.TempPrefix = fs.WindowsTempPrefix
|
|
|
defer func() {
|
|
|
- ignore.TempPrefix = originalPrefix
|
|
|
+ fs.TempPrefix = originalPrefix
|
|
|
}()
|
|
|
}
|
|
|
future := time.Now().Add(time.Hour)
|
|
|
- err := os.Chtimes(filepath.Join("testdata", ignore.TempName("file")), future, future)
|
|
|
+ err := os.Chtimes(filepath.Join("testdata", fs.TempName("file")), future, future)
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
@@ -191,14 +190,14 @@ func TestCopierFinder(t *testing.T) {
|
|
|
// After dropping out blocks found locally:
|
|
|
// Pull: 1, 5, 6, 8
|
|
|
|
|
|
- tempFile := filepath.Join("testdata", ignore.TempName("file2"))
|
|
|
+ tempFile := filepath.Join("testdata", fs.TempName("file2"))
|
|
|
err := os.Remove(tempFile)
|
|
|
if err != nil && !os.IsNotExist(err) {
|
|
|
t.Error(err)
|
|
|
}
|
|
|
|
|
|
existingBlocks := []int{0, 2, 3, 4, 0, 0, 7, 0}
|
|
|
- existingFile := setUpFile(ignore.TempName("file"), existingBlocks)
|
|
|
+ existingFile := setUpFile(fs.TempName("file"), existingBlocks)
|
|
|
requiredFile := existingFile
|
|
|
requiredFile.Blocks = blocks[1:]
|
|
|
requiredFile.Name = "file2"
|
|
@@ -261,7 +260,7 @@ func TestCopierFinder(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestWeakHash(t *testing.T) {
|
|
|
- tempFile := filepath.Join("testdata", ignore.TempName("weakhash"))
|
|
|
+ tempFile := filepath.Join("testdata", fs.TempName("weakhash"))
|
|
|
var shift int64 = 10
|
|
|
var size int64 = 1 << 20
|
|
|
expectBlocks := int(size / protocol.BlockSize)
|
|
@@ -466,12 +465,12 @@ func TestLastResortPulling(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
(<-finisherChan).fd.Close()
|
|
|
- os.Remove(filepath.Join("testdata", ignore.TempName("newfile")))
|
|
|
+ os.Remove(filepath.Join("testdata", fs.TempName("newfile")))
|
|
|
}
|
|
|
|
|
|
func TestDeregisterOnFailInCopy(t *testing.T) {
|
|
|
file := setUpFile("filex", []int{0, 2, 0, 0, 5, 0, 0, 8})
|
|
|
- defer os.Remove("testdata/" + ignore.TempName("filex"))
|
|
|
+ defer os.Remove("testdata/" + fs.TempName("filex"))
|
|
|
|
|
|
db := db.OpenMemory()
|
|
|
|
|
@@ -545,7 +544,7 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
|
|
|
|
|
func TestDeregisterOnFailInPull(t *testing.T) {
|
|
|
file := setUpFile("filex", []int{0, 2, 0, 0, 5, 0, 0, 8})
|
|
|
- defer os.Remove("testdata/" + ignore.TempName("filex"))
|
|
|
+ defer os.Remove("testdata/" + fs.TempName("filex"))
|
|
|
|
|
|
db := db.OpenMemory()
|
|
|
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|