mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
all: Even more boring linter fixes (#5501)
This commit is contained in:
parent
df5c1eaf01
commit
0b2cabbc31
@ -81,7 +81,7 @@ func (w *AtomicWriter) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to not leave temp file around, but ignore error.
|
// Try to not leave temp file around, but ignore error.
|
||||||
defer w.fs.Remove(w.next.Name())
|
defer func() { _ = w.fs.Remove(w.next.Name()) }()
|
||||||
|
|
||||||
if err := w.next.Sync(); err != nil {
|
if err := w.next.Sync(); err != nil {
|
||||||
w.err = err
|
w.err = err
|
||||||
@ -110,7 +110,7 @@ func (w *AtomicWriter) Close() error {
|
|||||||
|
|
||||||
// fsync the directory too
|
// fsync the directory too
|
||||||
if fd, err := w.fs.Open(filepath.Dir(w.next.Name())); err == nil {
|
if fd, err := w.fs.Open(filepath.Dir(w.next.Name())); err == nil {
|
||||||
fd.Sync()
|
_ = fd.Sync()
|
||||||
fd.Close()
|
fd.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func TryRename(filesystem fs.Filesystem, from, to string) error {
|
|||||||
func Rename(filesystem fs.Filesystem, from, to string) error {
|
func Rename(filesystem fs.Filesystem, from, to string) error {
|
||||||
// Don't leave a dangling temp file in case of rename error
|
// Don't leave a dangling temp file in case of rename error
|
||||||
if !(runtime.GOOS == "windows" && strings.EqualFold(from, to)) {
|
if !(runtime.GOOS == "windows" && strings.EqualFold(from, to)) {
|
||||||
defer filesystem.Remove(from)
|
defer func() { _ = filesystem.Remove(from) }()
|
||||||
}
|
}
|
||||||
return TryRename(filesystem, from, to)
|
return TryRename(filesystem, from, to)
|
||||||
}
|
}
|
||||||
@ -94,13 +94,13 @@ func withPreparedTarget(filesystem fs.Filesystem, from, to string, f func() erro
|
|||||||
// Make sure the destination directory is writeable
|
// Make sure the destination directory is writeable
|
||||||
toDir := filepath.Dir(to)
|
toDir := filepath.Dir(to)
|
||||||
if info, err := filesystem.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
|
if info, err := filesystem.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
|
||||||
filesystem.Chmod(toDir, 0755)
|
_ = filesystem.Chmod(toDir, 0755)
|
||||||
defer filesystem.Chmod(toDir, info.Mode())
|
defer func() { _ = filesystem.Chmod(toDir, info.Mode()) }()
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows, make sure the destination file is writeable (or we can't delete it)
|
// On Windows, make sure the destination file is writeable (or we can't delete it)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
filesystem.Chmod(to, 0666)
|
_ = filesystem.Chmod(to, 0666)
|
||||||
if !strings.EqualFold(from, to) {
|
if !strings.EqualFold(from, to) {
|
||||||
err := filesystem.Remove(to)
|
err := filesystem.Remove(to)
|
||||||
if err != nil && !fs.IsNotExist(err) {
|
if err != nil && !fs.IsNotExist(err) {
|
||||||
|
@ -26,9 +26,9 @@ func TestInWriteableDir(t *testing.T) {
|
|||||||
|
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
||||||
|
|
||||||
os.Mkdir("testdata", 0700)
|
_ = os.Mkdir("testdata", 0700)
|
||||||
os.Mkdir("testdata/rw", 0700)
|
_ = os.Mkdir("testdata/rw", 0700)
|
||||||
os.Mkdir("testdata/ro", 0500)
|
_ = os.Mkdir("testdata/ro", 0500)
|
||||||
|
|
||||||
create := func(name string) error {
|
create := func(name string) error {
|
||||||
fd, err := os.Create(name)
|
fd, err := os.Create(name)
|
||||||
@ -87,7 +87,7 @@ func TestInWritableDirWindowsRemove(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.Chmod("testdata/windows/ro/readonlynew", 0700)
|
defer func() { _ = os.Chmod("testdata/windows/ro/readonlynew", 0700) }()
|
||||||
defer os.RemoveAll("testdata")
|
defer os.RemoveAll("testdata")
|
||||||
|
|
||||||
create := func(name string) error {
|
create := func(name string) error {
|
||||||
@ -99,12 +99,12 @@ func TestInWritableDirWindowsRemove(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Mkdir("testdata", 0700)
|
_ = os.Mkdir("testdata", 0700)
|
||||||
|
|
||||||
os.Mkdir("testdata/windows", 0500)
|
_ = os.Mkdir("testdata/windows", 0500)
|
||||||
os.Mkdir("testdata/windows/ro", 0500)
|
_ = os.Mkdir("testdata/windows/ro", 0500)
|
||||||
create("testdata/windows/ro/readonly")
|
_ = create("testdata/windows/ro/readonly")
|
||||||
os.Chmod("testdata/windows/ro/readonly", 0500)
|
_ = os.Chmod("testdata/windows/ro/readonly", 0500)
|
||||||
|
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ func TestInWritableDirWindowsRemoveAll(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.Chmod("testdata/windows/ro/readonlynew", 0700)
|
defer func() { _ = os.Chmod("testdata/windows/ro/readonlynew", 0700) }()
|
||||||
defer os.RemoveAll("testdata")
|
defer func() { _ = os.RemoveAll("testdata") }()
|
||||||
|
|
||||||
create := func(name string) error {
|
create := func(name string) error {
|
||||||
fd, err := os.Create(name)
|
fd, err := os.Create(name)
|
||||||
@ -140,12 +140,12 @@ func TestInWritableDirWindowsRemoveAll(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Mkdir("testdata", 0700)
|
_ = os.Mkdir("testdata", 0700)
|
||||||
|
|
||||||
os.Mkdir("testdata/windows", 0500)
|
_ = os.Mkdir("testdata/windows", 0500)
|
||||||
os.Mkdir("testdata/windows/ro", 0500)
|
_ = os.Mkdir("testdata/windows/ro", 0500)
|
||||||
create("testdata/windows/ro/readonly")
|
_ = create("testdata/windows/ro/readonly")
|
||||||
os.Chmod("testdata/windows/ro/readonly", 0500)
|
_ = os.Chmod("testdata/windows/ro/readonly", 0500)
|
||||||
|
|
||||||
if err := os.RemoveAll("testdata/windows"); err != nil {
|
if err := os.RemoveAll("testdata/windows"); err != nil {
|
||||||
t.Errorf("Unexpected error: %s", err)
|
t.Errorf("Unexpected error: %s", err)
|
||||||
@ -162,8 +162,8 @@ func TestInWritableDirWindowsRename(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.Chmod("testdata/windows/ro/readonlynew", 0700)
|
defer func() { _ = os.Chmod("testdata/windows/ro/readonlynew", 0700) }()
|
||||||
defer os.RemoveAll("testdata")
|
defer func() { _ = os.RemoveAll("testdata") }()
|
||||||
|
|
||||||
create := func(name string) error {
|
create := func(name string) error {
|
||||||
fd, err := os.Create(name)
|
fd, err := os.Create(name)
|
||||||
@ -174,12 +174,12 @@ func TestInWritableDirWindowsRename(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Mkdir("testdata", 0700)
|
_ = os.Mkdir("testdata", 0700)
|
||||||
|
|
||||||
os.Mkdir("testdata/windows", 0500)
|
_ = os.Mkdir("testdata/windows", 0500)
|
||||||
os.Mkdir("testdata/windows/ro", 0500)
|
_ = os.Mkdir("testdata/windows/ro", 0500)
|
||||||
create("testdata/windows/ro/readonly")
|
_ = create("testdata/windows/ro/readonly")
|
||||||
os.Chmod("testdata/windows/ro/readonly", 0500)
|
_ = os.Chmod("testdata/windows/ro/readonly", 0500)
|
||||||
|
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, ".")
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ func TestIsDeleted(t *testing.T) {
|
|||||||
|
|
||||||
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
|
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
|
||||||
|
|
||||||
testFs.MkdirAll("dir", 0777)
|
_ = testFs.MkdirAll("dir", 0777)
|
||||||
for _, f := range []string{"file", "del.file", "dir.file", "dir/file"} {
|
for _, f := range []string{"file", "del.file", "dir.file", "dir/file"} {
|
||||||
fd, err := testFs.Create(f)
|
fd, err := testFs.Create(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -242,7 +242,7 @@ func TestIsDeleted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
// Can't create unreadable dir on windows
|
// Can't create unreadable dir on windows
|
||||||
testFs.MkdirAll("inacc", 0777)
|
_ = testFs.MkdirAll("inacc", 0777)
|
||||||
if err := testFs.Chmod("inacc", 0000); err == nil {
|
if err := testFs.Chmod("inacc", 0000); err == nil {
|
||||||
if _, err := testFs.Lstat("inacc/file"); fs.IsPermission(err) {
|
if _, err := testFs.Lstat("inacc/file"); fs.IsPermission(err) {
|
||||||
// May fail e.g. if tests are run as root -> just skip
|
// May fail e.g. if tests are run as root -> just skip
|
||||||
@ -265,6 +265,6 @@ func TestIsDeleted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testFs.Chmod("inacc", 0777)
|
_ = testFs.Chmod("inacc", 0777)
|
||||||
os.RemoveAll("testdata")
|
os.RemoveAll("testdata")
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func TestTraversesSymlink(t *testing.T) {
|
|||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir)
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir)
|
||||||
fs.MkdirAll("a/b/c", 0755)
|
_ = fs.MkdirAll("a/b/c", 0755)
|
||||||
if err = osutil.DebugSymlinkForTestsOnly(filepath.Join(fs.URI(), "a", "b"), filepath.Join(fs.URI(), "a", "l")); err != nil {
|
if err = osutil.DebugSymlinkForTestsOnly(filepath.Join(fs.URI(), "a", "b"), filepath.Join(fs.URI(), "a", "l")); err != nil {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip("Symlinks aren't working")
|
t.Skip("Symlinks aren't working")
|
||||||
@ -78,7 +78,7 @@ func TestIssue4875(t *testing.T) {
|
|||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir)
|
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir)
|
||||||
testFs.MkdirAll("a/b/c", 0755)
|
_ = testFs.MkdirAll("a/b/c", 0755)
|
||||||
if err = osutil.DebugSymlinkForTestsOnly(filepath.Join(testFs.URI(), "a", "b"), filepath.Join(testFs.URI(), "a", "l")); err != nil {
|
if err = osutil.DebugSymlinkForTestsOnly(filepath.Join(testFs.URI(), "a", "b"), filepath.Join(testFs.URI(), "a", "l")); err != nil {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip("Symlinks aren't working")
|
t.Skip("Symlinks aren't working")
|
||||||
@ -107,7 +107,7 @@ func BenchmarkTraversesSymlink(b *testing.B) {
|
|||||||
os.RemoveAll("testdata")
|
os.RemoveAll("testdata")
|
||||||
defer os.RemoveAll("testdata")
|
defer os.RemoveAll("testdata")
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
|
||||||
fs.MkdirAll("a/b/c", 0755)
|
_ = fs.MkdirAll("a/b/c", 0755)
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
traversesSymlinkResult = osutil.TraversesSymlink(fs, "a/b/c")
|
traversesSymlinkResult = osutil.TraversesSymlink(fs, "a/b/c")
|
||||||
|
@ -132,8 +132,8 @@ func getTCPConnectionPair() (net.Conn, net.Conn, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the buffer sizes etc as usual
|
// Set the buffer sizes etc as usual
|
||||||
dialer.SetTCPOptions(conn0)
|
_ = dialer.SetTCPOptions(conn0)
|
||||||
dialer.SetTCPOptions(conn1)
|
_ = dialer.SetTCPOptions(conn1)
|
||||||
|
|
||||||
return conn0, conn1, nil
|
return conn0, conn1, nil
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func repeatedDeviceID(v byte) (d DeviceID) {
|
|||||||
func NewDeviceID(rawCert []byte) DeviceID {
|
func NewDeviceID(rawCert []byte) DeviceID {
|
||||||
var n DeviceID
|
var n DeviceID
|
||||||
hf := sha256.New()
|
hf := sha256.New()
|
||||||
hf.Write(rawCert)
|
_, _ = hf.Write(rawCert)
|
||||||
hf.Sum(n[:0])
|
hf.Sum(n[:0])
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,13 @@ func TestMarshallingDeviceID(t *testing.T) {
|
|||||||
n2 := DeviceID{}
|
n2 := DeviceID{}
|
||||||
|
|
||||||
bs, _ := n0.MarshalText()
|
bs, _ := n0.MarshalText()
|
||||||
n1.UnmarshalText(bs)
|
if err := n1.UnmarshalText(bs); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
bs, _ = n1.MarshalText()
|
bs, _ = n1.MarshalText()
|
||||||
n2.UnmarshalText(bs)
|
if err := n2.UnmarshalText(bs); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if n2.String() != n0.String() {
|
if n2.String() != n0.String() {
|
||||||
t.Errorf("String marshalling error; %q != %q", n2.String(), n0.String())
|
t.Errorf("String marshalling error; %q != %q", n2.String(), n0.String())
|
||||||
|
@ -7,12 +7,9 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var spaceRe = regexp.MustCompile(`\s`)
|
|
||||||
|
|
||||||
func TestVersion14Hello(t *testing.T) {
|
func TestVersion14Hello(t *testing.T) {
|
||||||
// Tests that we can send and receive a version 0.14 hello message.
|
// Tests that we can send and receive a version 0.14 hello message.
|
||||||
|
|
||||||
|
@ -175,7 +175,6 @@ type rawConnection struct {
|
|||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
closeOnce sync.Once
|
closeOnce sync.Once
|
||||||
sendCloseOnce sync.Once
|
sendCloseOnce sync.Once
|
||||||
writerExited chan struct{}
|
|
||||||
compression Compression
|
compression Compression
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +226,10 @@ func NewConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, receiv
|
|||||||
// Start creates the goroutines for sending and receiving of messages. It must
|
// Start creates the goroutines for sending and receiving of messages. It must
|
||||||
// be called exactly once after creating a connection.
|
// be called exactly once after creating a connection.
|
||||||
func (c *rawConnection) Start() {
|
func (c *rawConnection) Start() {
|
||||||
go c.readerLoop()
|
go func() {
|
||||||
|
err := c.readerLoop()
|
||||||
|
c.internalClose(err)
|
||||||
|
}()
|
||||||
go c.writerLoop()
|
go c.writerLoop()
|
||||||
go c.pingSender()
|
go c.pingSender()
|
||||||
go c.pingReceiver()
|
go c.pingReceiver()
|
||||||
@ -336,10 +338,6 @@ func (c *rawConnection) ping() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *rawConnection) readerLoop() (err error) {
|
func (c *rawConnection) readerLoop() (err error) {
|
||||||
defer func() {
|
|
||||||
c.internalClose(err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
fourByteBuf := make([]byte, 4)
|
fourByteBuf := make([]byte, 4)
|
||||||
state := stateInitial
|
state := stateInitial
|
||||||
for {
|
for {
|
||||||
|
@ -69,8 +69,8 @@ func TestClose(t *testing.T) {
|
|||||||
t.Error("Ping should not return true")
|
t.Error("Ping should not return true")
|
||||||
}
|
}
|
||||||
|
|
||||||
c0.Index("default", nil)
|
_ = c0.Index("default", nil)
|
||||||
c0.Index("default", nil)
|
_ = c0.Index("default", nil)
|
||||||
|
|
||||||
if _, err := c0.Request("default", "foo", 0, 0, nil, 0, false); err == nil {
|
if _, err := c0.Request("default", "foo", 0, 0, nil, 0, false); err == nil {
|
||||||
t.Error("Request should return an error")
|
t.Error("Request should return an error")
|
||||||
@ -225,8 +225,8 @@ func testMarshal(t *testing.T, prefix string, m1, m2 message) bool {
|
|||||||
bs1, _ := json.MarshalIndent(m1, "", " ")
|
bs1, _ := json.MarshalIndent(m1, "", " ")
|
||||||
bs2, _ := json.MarshalIndent(m2, "", " ")
|
bs2, _ := json.MarshalIndent(m2, "", " ")
|
||||||
if !bytes.Equal(bs1, bs2) {
|
if !bytes.Equal(bs1, bs2) {
|
||||||
ioutil.WriteFile(prefix+"-1.txt", bs1, 0644)
|
_ = ioutil.WriteFile(prefix+"-1.txt", bs1, 0644)
|
||||||
ioutil.WriteFile(prefix+"-2.txt", bs2, 0644)
|
_ = ioutil.WriteFile(prefix+"-2.txt", bs2, 0644)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func Intn(n int) int {
|
|||||||
// suitable for use a predictable random seed.
|
// suitable for use a predictable random seed.
|
||||||
func SeedFromBytes(bs []byte) int64 {
|
func SeedFromBytes(bs []byte) int64 {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write(bs)
|
_, _ = h.Write(bs)
|
||||||
s := h.Sum(nil)
|
s := h.Sum(nil)
|
||||||
// The MD5 hash of the byte slice is 16 bytes long. We interpret it as two
|
// The MD5 hash of the byte slice is 16 bytes long. We interpret it as two
|
||||||
// uint64s and XOR them together.
|
// uint64s and XOR them together.
|
||||||
|
@ -114,7 +114,7 @@ func (p *Process) Start(bin string, args ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) wait() {
|
func (p *Process) wait() {
|
||||||
p.cmd.Wait()
|
_ = p.cmd.Wait()
|
||||||
|
|
||||||
if p.logfd != nil {
|
if p.logfd != nil {
|
||||||
p.stopErr = p.checkForProblems(p.logfd)
|
p.stopErr = p.checkForProblems(p.logfd)
|
||||||
|
@ -27,7 +27,7 @@ func GetInvitationFromRelay(uri *url.URL, id syncthingprotocol.DeviceID, certs [
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn := tls.Client(rconn, configForCerts(certs))
|
conn := tls.Client(rconn, configForCerts(certs))
|
||||||
conn.SetDeadline(time.Now().Add(timeout))
|
_ = conn.SetDeadline(time.Now().Add(timeout))
|
||||||
|
|
||||||
if err := performHandshakeAndValidation(conn, uri); err != nil {
|
if err := performHandshakeAndValidation(conn, uri); err != nil {
|
||||||
return protocol.SessionInvitation{}, err
|
return protocol.SessionInvitation{}, err
|
||||||
@ -75,7 +75,7 @@ func JoinSession(invitation protocol.SessionInvitation) (net.Conn, error) {
|
|||||||
Key: invitation.Key,
|
Key: invitation.Key,
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.SetDeadline(time.Now().Add(10 * time.Second))
|
_ = conn.SetDeadline(time.Now().Add(10 * time.Second))
|
||||||
err = protocol.WriteMessage(conn, request)
|
err = protocol.WriteMessage(conn, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -86,7 +86,7 @@ func JoinSession(invitation protocol.SessionInvitation) (net.Conn, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.SetDeadline(time.Time{})
|
_ = conn.SetDeadline(time.Time{})
|
||||||
|
|
||||||
switch msg := message.(type) {
|
switch msg := message.(type) {
|
||||||
case protocol.Response:
|
case protocol.Response:
|
||||||
|
@ -116,7 +116,7 @@ func Validate(buf, hash []byte, weakHash uint32) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Copy error or mismatch, go to next algo.
|
// Copy error or mismatch, go to next algo.
|
||||||
rd.Seek(0, io.SeekStart)
|
_, _ = rd.Seek(0, io.SeekStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(hash) > 0 {
|
if len(hash) > 0 {
|
||||||
|
@ -112,10 +112,10 @@ func TestAdler32Variants(t *testing.T) {
|
|||||||
hf2 := rollingAdler32.New()
|
hf2 := rollingAdler32.New()
|
||||||
|
|
||||||
checkFn := func(data []byte) bool {
|
checkFn := func(data []byte) bool {
|
||||||
hf1.Write(data)
|
_, _ = hf1.Write(data)
|
||||||
sum1 := hf1.Sum32()
|
sum1 := hf1.Sum32()
|
||||||
|
|
||||||
hf2.Write(data)
|
_, _ = hf2.Write(data)
|
||||||
sum2 := hf2.Sum32()
|
sum2 := hf2.Sum32()
|
||||||
|
|
||||||
hf1.Reset()
|
hf1.Reset()
|
||||||
@ -127,7 +127,7 @@ func TestAdler32Variants(t *testing.T) {
|
|||||||
// protocol block sized data
|
// protocol block sized data
|
||||||
data := make([]byte, protocol.MinBlockSize)
|
data := make([]byte, protocol.MinBlockSize)
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
rand.Read(data)
|
_, _ = rand.Read(data)
|
||||||
if !checkFn(data) {
|
if !checkFn(data) {
|
||||||
t.Errorf("Hash mismatch on block sized data")
|
t.Errorf("Hash mismatch on block sized data")
|
||||||
}
|
}
|
||||||
@ -145,13 +145,13 @@ func TestAdler32Variants(t *testing.T) {
|
|||||||
windowSize := 128
|
windowSize := 128
|
||||||
|
|
||||||
hf3 := rollingAdler32.New()
|
hf3 := rollingAdler32.New()
|
||||||
hf3.Write(data[:windowSize])
|
_, _ = hf3.Write(data[:windowSize])
|
||||||
|
|
||||||
for i := windowSize; i < len(data); i++ {
|
for i := windowSize; i < len(data); i++ {
|
||||||
if i%windowSize == 0 {
|
if i%windowSize == 0 {
|
||||||
// let the reference function catch up
|
// let the reference function catch up
|
||||||
hf2.Reset()
|
hf2.Reset()
|
||||||
hf2.Write(data[i-windowSize : i])
|
_, _ = hf2.Write(data[i-windowSize : i])
|
||||||
|
|
||||||
// verify that they are in sync with the rolling function
|
// verify that they are in sync with the rolling function
|
||||||
sum2 := hf2.Sum32()
|
sum2 := hf2.Sum32()
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/rcrowley/go-metrics"
|
metrics "github.com/rcrowley/go-metrics"
|
||||||
"github.com/syncthing/syncthing/lib/events"
|
"github.com/syncthing/syncthing/lib/events"
|
||||||
"github.com/syncthing/syncthing/lib/fs"
|
"github.com/syncthing/syncthing/lib/fs"
|
||||||
"github.com/syncthing/syncthing/lib/ignore"
|
"github.com/syncthing/syncthing/lib/ignore"
|
||||||
@ -108,10 +108,10 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
go func() {
|
go func() {
|
||||||
hashFiles := w.walkAndHashFiles(ctx, toHashChan, finishedChan)
|
hashFiles := w.walkAndHashFiles(ctx, toHashChan, finishedChan)
|
||||||
if len(w.Subs) == 0 {
|
if len(w.Subs) == 0 {
|
||||||
w.Filesystem.Walk(".", hashFiles)
|
_ = w.Filesystem.Walk(".", hashFiles)
|
||||||
} else {
|
} else {
|
||||||
for _, sub := range w.Subs {
|
for _, sub := range w.Subs {
|
||||||
w.Filesystem.Walk(sub, hashFiles)
|
_ = w.Filesystem.Walk(sub, hashFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(toHashChan)
|
close(toHashChan)
|
||||||
@ -223,7 +223,7 @@ func (w *walker) walkAndHashFiles(ctx context.Context, toHashChan chan<- protoco
|
|||||||
if fs.IsTemporary(path) {
|
if fs.IsTemporary(path) {
|
||||||
l.Debugln("temporary:", path, "err:", err)
|
l.Debugln("temporary:", path, "err:", err)
|
||||||
if err == nil && info.IsRegular() && info.ModTime().Add(w.TempLifetime).Before(now) {
|
if err == nil && info.IsRegular() && info.ModTime().Add(w.TempLifetime).Before(now) {
|
||||||
w.Filesystem.Remove(path)
|
_ = w.Filesystem.Remove(path)
|
||||||
l.Debugln("removing temporary:", path, info.ModTime())
|
l.Debugln("removing temporary:", path, info.ModTime())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -216,7 +216,7 @@ func TestNormalization(t *testing.T) {
|
|||||||
if fd, err := testFs.OpenFile(filepath.Join("normalization", s1, s2), os.O_CREATE|os.O_EXCL, 0644); err != nil {
|
if fd, err := testFs.OpenFile(filepath.Join("normalization", s1, s2), os.O_CREATE|os.O_EXCL, 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
fd.Write([]byte("test"))
|
_, _ = fd.Write([]byte("test"))
|
||||||
fd.Close()
|
fd.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ func TestIssue1507(t *testing.T) {
|
|||||||
f := make(chan ScanResult, 100)
|
f := make(chan ScanResult, 100)
|
||||||
fn := w.walkAndHashFiles(context.TODO(), h, f)
|
fn := w.walkAndHashFiles(context.TODO(), h, f)
|
||||||
|
|
||||||
fn("", nil, protocol.ErrClosed)
|
_ = fn("", nil, protocol.ErrClosed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWalkSymlinkUnix(t *testing.T) {
|
func TestWalkSymlinkUnix(t *testing.T) {
|
||||||
@ -268,9 +268,9 @@ func TestWalkSymlinkUnix(t *testing.T) {
|
|||||||
|
|
||||||
// Create a folder with a symlink in it
|
// Create a folder with a symlink in it
|
||||||
os.RemoveAll("_symlinks")
|
os.RemoveAll("_symlinks")
|
||||||
os.Mkdir("_symlinks", 0755)
|
_ = os.Mkdir("_symlinks", 0755)
|
||||||
defer os.RemoveAll("_symlinks")
|
defer os.RemoveAll("_symlinks")
|
||||||
os.Symlink("../testdata", "_symlinks/link")
|
_ = os.Symlink("../testdata", "_symlinks/link")
|
||||||
|
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, "_symlinks")
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, "_symlinks")
|
||||||
for _, path := range []string{".", "link"} {
|
for _, path := range []string{".", "link"} {
|
||||||
@ -298,7 +298,7 @@ func TestWalkSymlinkWindows(t *testing.T) {
|
|||||||
// Create a folder with a symlink in it
|
// Create a folder with a symlink in it
|
||||||
name := "_symlinks-win"
|
name := "_symlinks-win"
|
||||||
os.RemoveAll(name)
|
os.RemoveAll(name)
|
||||||
os.Mkdir(name, 0755)
|
_ = os.Mkdir(name, 0755)
|
||||||
defer os.RemoveAll(name)
|
defer os.RemoveAll(name)
|
||||||
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, name)
|
fs := fs.NewFilesystem(fs.FilesystemTypeBasic, name)
|
||||||
if err := osutil.DebugSymlinkForTestsOnly("../testdata", "_symlinks/link"); err != nil {
|
if err := osutil.DebugSymlinkForTestsOnly("../testdata", "_symlinks/link"); err != nil {
|
||||||
|
@ -115,12 +115,12 @@ func cpuBenchOnce(duration time.Duration, newFn func() hash.Hash) float64 {
|
|||||||
chunkSize := 100 * 1 << 10
|
chunkSize := 100 * 1 << 10
|
||||||
h := newFn()
|
h := newFn()
|
||||||
bs := make([]byte, chunkSize)
|
bs := make([]byte, chunkSize)
|
||||||
rand.Reader.Read(bs)
|
_, _ = rand.Reader.Read(bs)
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
b := 0
|
b := 0
|
||||||
for time.Since(t0) < duration {
|
for time.Since(t0) < duration {
|
||||||
h.Write(bs)
|
_, _ = h.Write(bs)
|
||||||
b += chunkSize
|
b += chunkSize
|
||||||
}
|
}
|
||||||
h.Sum(nil)
|
h.Sum(nil)
|
||||||
@ -146,7 +146,7 @@ func verifyCorrectness() {
|
|||||||
input := "Syncthing Magic Testing Value\n"
|
input := "Syncthing Magic Testing Value\n"
|
||||||
|
|
||||||
h := New()
|
h := New()
|
||||||
h.Write([]byte(input))
|
_, _ = h.Write([]byte(input))
|
||||||
sum := hex.EncodeToString(h.Sum(nil))
|
sum := hex.EncodeToString(h.Sum(nil))
|
||||||
if sum != correct {
|
if sum != correct {
|
||||||
panic("sha256 is broken")
|
panic("sha256 is broken")
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sasha-s/go-deadlock"
|
deadlock "github.com/sasha-s/go-deadlock"
|
||||||
"github.com/syncthing/syncthing/lib/logger"
|
"github.com/syncthing/syncthing/lib/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -186,9 +186,9 @@ func (l *DowngradingListener) AcceptNoWrapTLS() (net.Conn, bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var first [1]byte
|
var first [1]byte
|
||||||
conn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
_ = conn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
||||||
n, err := conn.Read(first[:])
|
n, err := conn.Read(first[:])
|
||||||
conn.SetReadDeadline(time.Time{})
|
_ = conn.SetReadDeadline(time.Time{})
|
||||||
if err != nil || n == 0 {
|
if err != nil || n == 0 {
|
||||||
// We hit a read error here, but the Accept() call succeeded so we must not return an error.
|
// We hit a read error here, but the Accept() call succeeded so we must not return an error.
|
||||||
// We return the connection as is with a special error which handles this
|
// We return the connection as is with a special error which handles this
|
||||||
@ -308,7 +308,7 @@ JpJcUNtrf1XK49IlpWW1Ds8seQsSg7/9BQ==
|
|||||||
|
|
||||||
c := tls.Client(c0, clientCfg)
|
c := tls.Client(c0, clientCfg)
|
||||||
go func() {
|
go func() {
|
||||||
c.Handshake()
|
_ = c.Handshake()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
s := tls.Server(c1, serverCfg)
|
s := tls.Server(c1, serverCfg)
|
||||||
|
@ -201,8 +201,8 @@ func upgradeToURL(archiveName, binary string, url string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if os.Rename(fname, binary); err != nil {
|
if err := os.Rename(fname, binary); err != nil {
|
||||||
os.Rename(old, binary)
|
_ = os.Rename(old, binary)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -59,8 +59,8 @@ func (v Simple) Archive(filePath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if fs.IsNotExist(err) {
|
if fs.IsNotExist(err) {
|
||||||
l.Debugln("creating versions dir .stversions")
|
l.Debugln("creating versions dir .stversions")
|
||||||
v.fs.Mkdir(versionsDir, 0755)
|
_ = v.fs.Mkdir(versionsDir, 0755)
|
||||||
v.fs.Hide(versionsDir)
|
_ = v.fs.Hide(versionsDir)
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -239,8 +239,8 @@ func (v *Staggered) Archive(filePath string) error {
|
|||||||
if _, err := v.versionsFs.Stat("."); err != nil {
|
if _, err := v.versionsFs.Stat("."); err != nil {
|
||||||
if fs.IsNotExist(err) {
|
if fs.IsNotExist(err) {
|
||||||
l.Debugln("creating versions dir", v.versionsFs)
|
l.Debugln("creating versions dir", v.versionsFs)
|
||||||
v.versionsFs.MkdirAll(".", 0755)
|
_ = v.versionsFs.MkdirAll(".", 0755)
|
||||||
v.versionsFs.Hide(".")
|
_ = v.versionsFs.Hide(".")
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func TestStaggeredVersioningVersionCount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sort.Strings(delete)
|
sort.Strings(delete)
|
||||||
|
|
||||||
os.MkdirAll("testdata/.stversions", 0755)
|
_ = os.MkdirAll("testdata/.stversions", 0755)
|
||||||
defer os.RemoveAll("testdata")
|
defer os.RemoveAll("testdata")
|
||||||
|
|
||||||
v := NewStaggered("", fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata"), map[string]string{"maxAge": strconv.Itoa(365 * 86400)}).(*Staggered)
|
v := NewStaggered("", fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata"), map[string]string{"maxAge": strconv.Itoa(365 * 86400)}).(*Staggered)
|
||||||
|
@ -65,7 +65,7 @@ func (t *Trashcan) Archive(filePath string) error {
|
|||||||
if err := t.fs.MkdirAll(versionsDir, 0777); err != nil {
|
if err := t.fs.MkdirAll(versionsDir, 0777); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
t.fs.Hide(versionsDir)
|
_ = t.fs.Hide(versionsDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Debugln("archiving", filePath)
|
l.Debugln("archiving", filePath)
|
||||||
@ -84,7 +84,7 @@ func (t *Trashcan) Archive(filePath string) error {
|
|||||||
// Set the mtime to the time the file was deleted. This is used by the
|
// Set the mtime to the time the file was deleted. This is used by the
|
||||||
// cleanout routine. If this fails things won't work optimally but there's
|
// cleanout routine. If this fails things won't work optimally but there's
|
||||||
// not much we can do about it so we ignore the error.
|
// not much we can do about it so we ignore the error.
|
||||||
t.fs.Chtimes(archivedPath, time.Now(), time.Now())
|
_ = t.fs.Chtimes(archivedPath, time.Now(), time.Now())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ func (t *Trashcan) cleanoutArchive() error {
|
|||||||
|
|
||||||
if info.ModTime().Before(cutoff) {
|
if info.ModTime().Before(cutoff) {
|
||||||
// The file is too old; remove it.
|
// The file is too old; remove it.
|
||||||
t.fs.Remove(path)
|
_ = t.fs.Remove(path)
|
||||||
} else {
|
} else {
|
||||||
// Keep this file, and remember it so we don't unnecessarily try
|
// Keep this file, and remember it so we don't unnecessarily try
|
||||||
// to remove this directory.
|
// to remove this directory.
|
||||||
|
@ -42,7 +42,7 @@ func TestTrashcanCleanout(t *testing.T) {
|
|||||||
|
|
||||||
oldTime := time.Now().Add(-8 * 24 * time.Hour)
|
oldTime := time.Now().Add(-8 * 24 * time.Hour)
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
os.MkdirAll(filepath.Dir(tc.file), 0777)
|
_ = os.MkdirAll(filepath.Dir(tc.file), 0777)
|
||||||
if err := ioutil.WriteFile(tc.file, []byte("data"), 0644); err != nil {
|
if err := ioutil.WriteFile(tc.file, []byte("data"), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -65,46 +65,71 @@ func TestAggregate(t *testing.T) {
|
|||||||
|
|
||||||
folderCfg := defaultFolderCfg.Copy()
|
folderCfg := defaultFolderCfg.Copy()
|
||||||
folderCfg.ID = "Aggregate"
|
folderCfg.ID = "Aggregate"
|
||||||
ctx, _ := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
a := newAggregator(folderCfg, ctx)
|
a := newAggregator(folderCfg, ctx)
|
||||||
|
|
||||||
// checks whether maxFilesPerDir events in one dir are kept as is
|
// checks whether maxFilesPerDir events in one dir are kept as is
|
||||||
for i := 0; i < maxFilesPerDir; i++ {
|
for i := 0; i < maxFilesPerDir; i++ {
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", strconv.Itoa(i)), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", strconv.Itoa(i)),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
}
|
}
|
||||||
if l := len(getEventPaths(a.root, ".", a)); l != maxFilesPerDir {
|
if l := len(getEventPaths(a.root, ".", a)); l != maxFilesPerDir {
|
||||||
t.Errorf("Unexpected number of events stored, got %v, expected %v", l, maxFilesPerDir)
|
t.Errorf("Unexpected number of events stored, got %v, expected %v", l, maxFilesPerDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks whether maxFilesPerDir+1 events in one dir are aggregated to parent dir
|
// checks whether maxFilesPerDir+1 events in one dir are aggregated to parent dir
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", "new"), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", "new"),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
||||||
|
|
||||||
// checks that adding an event below "parent" does not change anything
|
// checks that adding an event below "parent" does not change anything
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", "extra"), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", "extra"),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
||||||
|
|
||||||
// again test aggregation in "parent" but with event in subdirs
|
// again test aggregation in "parent" but with event in subdirs
|
||||||
a = newAggregator(folderCfg, ctx)
|
a = newAggregator(folderCfg, ctx)
|
||||||
for i := 0; i < maxFilesPerDir; i++ {
|
for i := 0; i < maxFilesPerDir; i++ {
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", strconv.Itoa(i)), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", strconv.Itoa(i)),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
}
|
}
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", "sub", "new"), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", "sub", "new"),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"parent"})
|
||||||
|
|
||||||
// test aggregation in root
|
// test aggregation in root
|
||||||
a = newAggregator(folderCfg, ctx)
|
a = newAggregator(folderCfg, ctx)
|
||||||
for i := 0; i < maxFiles; i++ {
|
for i := 0; i < maxFiles; i++ {
|
||||||
a.newEvent(fs.Event{strconv.Itoa(i), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: strconv.Itoa(i),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
}
|
}
|
||||||
if len(getEventPaths(a.root, ".", a)) != maxFiles {
|
if len(getEventPaths(a.root, ".", a)) != maxFiles {
|
||||||
t.Errorf("Unexpected number of events stored in root")
|
t.Errorf("Unexpected number of events stored in root")
|
||||||
}
|
}
|
||||||
a.newEvent(fs.Event{filepath.Join("parent", "sub", "new"), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join("parent", "sub", "new"),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
||||||
|
|
||||||
// checks that adding an event when "." is already stored is a noop
|
// checks that adding an event when "." is already stored is a noop
|
||||||
a.newEvent(fs.Event{"anythingelse", fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: "anythingelse",
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
||||||
|
|
||||||
a = newAggregator(folderCfg, ctx)
|
a = newAggregator(folderCfg, ctx)
|
||||||
@ -115,7 +140,10 @@ func TestAggregate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
for i := 0; i < filesPerDir; i++ {
|
for i := 0; i < filesPerDir; i++ {
|
||||||
a.newEvent(fs.Event{filepath.Join(dir, strconv.Itoa(i)), fs.NonRemove}, inProgress)
|
a.newEvent(fs.Event{
|
||||||
|
Name: filepath.Join(dir, strconv.Itoa(i)),
|
||||||
|
Type: fs.NonRemove,
|
||||||
|
}, inProgress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
compareBatchToExpectedDirect(t, getEventPaths(a.root, ".", a), []string{"."})
|
||||||
|
@ -42,7 +42,7 @@ func BenchmarkWeakHashAdler32(b *testing.B) {
|
|||||||
hf := adler32.New()
|
hf := adler32.New()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
hf.Write(data)
|
_, _ = hf.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = hf.Sum32()
|
_ = hf.Sum32()
|
||||||
@ -52,7 +52,7 @@ func BenchmarkWeakHashAdler32(b *testing.B) {
|
|||||||
func BenchmarkWeakHashAdler32Roll(b *testing.B) {
|
func BenchmarkWeakHashAdler32Roll(b *testing.B) {
|
||||||
data := make([]byte, size)
|
data := make([]byte, size)
|
||||||
hf := adler32.New()
|
hf := adler32.New()
|
||||||
hf.Write(data)
|
_, _ = hf.Write(data)
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ func BenchmarkWeakHashRabinKarp64(b *testing.B) {
|
|||||||
hf := rabinkarp64.New()
|
hf := rabinkarp64.New()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
hf.Write(data)
|
_, _ = hf.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = hf.Sum64()
|
_ = hf.Sum64()
|
||||||
|
Loading…
Reference in New Issue
Block a user