all: Correct various typos (#8870)
This commit is contained in:
parent
66faea7712
commit
ddce692f72
|
@ -66,7 +66,7 @@ func generateFiles(dir string, files, maxexp int, srcname string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateOneFile(fd io.ReadSeeker, p1 string, s int64) error {
|
func generateOneFile(fd io.ReadSeeker, p1 string, s int64) error {
|
||||||
src := io.LimitReader(&inifiteReader{fd}, s)
|
src := io.LimitReader(&infiniteReader{fd}, s)
|
||||||
dst, err := os.Create(p1)
|
dst, err := os.Create(p1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -105,11 +105,11 @@ func readRand(bs []byte) (int, error) {
|
||||||
return len(bs), nil
|
return len(bs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type inifiteReader struct {
|
type infiniteReader struct {
|
||||||
rd io.ReadSeeker
|
rd io.ReadSeeker
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *inifiteReader) Read(bs []byte) (int, error) {
|
func (i *infiniteReader) Read(bs []byte) (int, error) {
|
||||||
n, err := i.rd.Read(bs)
|
n, err := i.rd.Read(bs)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = nil
|
err = nil
|
||||||
|
|
|
@ -70,7 +70,7 @@ angular.module('syncthing.core')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// inform syncthingContoller that a modal is ready
|
// inform syncthingController that a modal is ready
|
||||||
scope.$parent.modalLoaded();
|
scope.$parent.modalLoaded();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -261,7 +261,7 @@ func TestNextDialRegistryCleanup(t *testing.T) {
|
||||||
},
|
},
|
||||||
// Threshold reached, but outside of cooldown delay
|
// Threshold reached, but outside of cooldown delay
|
||||||
{
|
{
|
||||||
attempts: dialCoolDownMaxAttemps,
|
attempts: dialCoolDownMaxAttempts,
|
||||||
coolDownIntervalStart: firsts[2],
|
coolDownIntervalStart: firsts[2],
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
@ -281,11 +281,11 @@ func TestNextDialRegistryCleanup(t *testing.T) {
|
||||||
},
|
},
|
||||||
// attempts at threshold, inside delay
|
// attempts at threshold, inside delay
|
||||||
{
|
{
|
||||||
attempts: dialCoolDownMaxAttemps,
|
attempts: dialCoolDownMaxAttempts,
|
||||||
coolDownIntervalStart: firsts[0],
|
coolDownIntervalStart: firsts[0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
attempts: dialCoolDownMaxAttemps,
|
attempts: dialCoolDownMaxAttempts,
|
||||||
coolDownIntervalStart: firsts[1],
|
coolDownIntervalStart: firsts[1],
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -1196,9 +1196,9 @@ func (r nextDialRegistry) get(device protocol.DeviceID, addr string) time.Time {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dialCoolDownInterval = 2 * time.Minute
|
dialCoolDownInterval = 2 * time.Minute
|
||||||
dialCoolDownDelay = 5 * time.Minute
|
dialCoolDownDelay = 5 * time.Minute
|
||||||
dialCoolDownMaxAttemps = 3
|
dialCoolDownMaxAttempts = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// redialDevice marks the device for immediate redial, unless the remote keeps
|
// redialDevice marks the device for immediate redial, unless the remote keeps
|
||||||
|
@ -1217,7 +1217,7 @@ func (r nextDialRegistry) redialDevice(device protocol.DeviceID, now time.Time)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if dev.attempts == 0 || now.Before(dev.coolDownIntervalStart.Add(dialCoolDownInterval)) {
|
if dev.attempts == 0 || now.Before(dev.coolDownIntervalStart.Add(dialCoolDownInterval)) {
|
||||||
if dev.attempts >= dialCoolDownMaxAttemps {
|
if dev.attempts >= dialCoolDownMaxAttempts {
|
||||||
// Device has been force redialed too often - let it cool down.
|
// Device has been force redialed too often - let it cool down.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1228,7 +1228,7 @@ func (r nextDialRegistry) redialDevice(device protocol.DeviceID, now time.Time)
|
||||||
dev.nextDial = make(map[string]time.Time)
|
dev.nextDial = make(map[string]time.Time)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if dev.attempts >= dialCoolDownMaxAttemps && now.Before(dev.coolDownIntervalStart.Add(dialCoolDownDelay)) {
|
if dev.attempts >= dialCoolDownMaxAttempts && now.Before(dev.coolDownIntervalStart.Add(dialCoolDownDelay)) {
|
||||||
return // Still cooling down
|
return // Still cooling down
|
||||||
}
|
}
|
||||||
delete(r, device)
|
delete(r, device)
|
||||||
|
@ -1256,7 +1256,7 @@ func (r nextDialRegistry) sleepDurationAndCleanup(now time.Time) time.Duration {
|
||||||
}
|
}
|
||||||
if dev.attempts > 0 {
|
if dev.attempts > 0 {
|
||||||
interval := dialCoolDownInterval
|
interval := dialCoolDownInterval
|
||||||
if dev.attempts >= dialCoolDownMaxAttemps {
|
if dev.attempts >= dialCoolDownMaxAttempts {
|
||||||
interval = dialCoolDownDelay
|
interval = dialCoolDownDelay
|
||||||
}
|
}
|
||||||
if now.After(dev.coolDownIntervalStart.Add(interval)) {
|
if now.After(dev.coolDownIntervalStart.Add(interval)) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestIsInternal(t *testing.T) {
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
res := IsInternal(filepath.FromSlash(tc.file))
|
res := IsInternal(filepath.FromSlash(tc.file))
|
||||||
if res != tc.internal {
|
if res != tc.internal {
|
||||||
t.Errorf("Unexpected result: IsInteral(%q): %v should be %v", tc.file, res, tc.internal)
|
t.Errorf("Unexpected result: IsInternal(%q): %v should be %v", tc.file, res, tc.internal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ var (
|
||||||
// ErrTooOldVersion is returned by ExchangeHello when the other side
|
// ErrTooOldVersion is returned by ExchangeHello when the other side
|
||||||
// speaks an older, incompatible version of the protocol.
|
// speaks an older, incompatible version of the protocol.
|
||||||
ErrTooOldVersion = errors.New("the remote device speaks an older version of the protocol not compatible with this version")
|
ErrTooOldVersion = errors.New("the remote device speaks an older version of the protocol not compatible with this version")
|
||||||
// ErrUnknownMagic is returned by ExchangeHellow when the other side
|
// ErrUnknownMagic is returned by ExchangeHello when the other side
|
||||||
// speaks something entirely unknown.
|
// speaks something entirely unknown.
|
||||||
ErrUnknownMagic = errors.New("the remote device speaks an unknown (newer?) version of the protocol")
|
ErrUnknownMagic = errors.New("the remote device speaks an unknown (newer?) version of the protocol")
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,7 @@ package util
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestZeroByteSempahore(_ *testing.T) {
|
func TestZeroByteSemaphore(_ *testing.T) {
|
||||||
// A semaphore with zero capacity is just a no-op.
|
// A semaphore with zero capacity is just a no-op.
|
||||||
|
|
||||||
s := NewSemaphore(0)
|
s := NewSemaphore(0)
|
||||||
|
@ -19,7 +19,7 @@ func TestZeroByteSempahore(_ *testing.T) {
|
||||||
s.Give(1 << 30)
|
s.Give(1 << 30)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestByteSempahoreCapChangeUp(t *testing.T) {
|
func TestByteSemaphoreCapChangeUp(t *testing.T) {
|
||||||
// Waiting takes should unblock when the capacity increases
|
// Waiting takes should unblock when the capacity increases
|
||||||
|
|
||||||
s := NewSemaphore(100)
|
s := NewSemaphore(100)
|
||||||
|
@ -42,7 +42,7 @@ func TestByteSempahoreCapChangeUp(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestByteSempahoreCapChangeDown1(t *testing.T) {
|
func TestByteSemaphoreCapChangeDown1(t *testing.T) {
|
||||||
// Things should make sense when capacity is adjusted down
|
// Things should make sense when capacity is adjusted down
|
||||||
|
|
||||||
s := NewSemaphore(100)
|
s := NewSemaphore(100)
|
||||||
|
@ -63,7 +63,7 @@ func TestByteSempahoreCapChangeDown1(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestByteSempahoreCapChangeDown2(t *testing.T) {
|
func TestByteSemaphoreCapChangeDown2(t *testing.T) {
|
||||||
// Things should make sense when capacity is adjusted down, different case
|
// Things should make sense when capacity is adjusted down, different case
|
||||||
|
|
||||||
s := NewSemaphore(100)
|
s := NewSemaphore(100)
|
||||||
|
@ -84,7 +84,7 @@ func TestByteSempahoreCapChangeDown2(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestByteSempahoreGiveMore(t *testing.T) {
|
func TestByteSemaphoreGiveMore(t *testing.T) {
|
||||||
// We shouldn't end up with more available than we have capacity...
|
// We shouldn't end up with more available than we have capacity...
|
||||||
|
|
||||||
s := NewSemaphore(100)
|
s := NewSemaphore(100)
|
||||||
|
|
|
@ -83,7 +83,7 @@ func generateFilesWithTime(dir string, files, maxexp int, srcname string, t0 tim
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateOneFile(fd io.ReadSeeker, p1 string, s int64, t0 time.Time) error {
|
func generateOneFile(fd io.ReadSeeker, p1 string, s int64, t0 time.Time) error {
|
||||||
src := io.LimitReader(&inifiteReader{fd}, int64(s))
|
src := io.LimitReader(&infiniteReader{fd}, int64(s))
|
||||||
dst, err := os.Create(p1)
|
dst, err := os.Create(p1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -265,11 +265,11 @@ func randomName() string {
|
||||||
return fmt.Sprintf("%x", b[:])
|
return fmt.Sprintf("%x", b[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
type inifiteReader struct {
|
type infiniteReader struct {
|
||||||
rd io.ReadSeeker
|
rd io.ReadSeeker
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *inifiteReader) Read(bs []byte) (int, error) {
|
func (i *infiniteReader) Read(bs []byte) (int, error) {
|
||||||
n, err := i.rd.Read(bs)
|
n, err := i.rd.Read(bs)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = nil
|
err = nil
|
||||||
|
|
Loading…
Reference in New Issue