mirror of
https://github.com/rclone/rclone
synced 2024-12-22 13:03:02 +01:00
Fix problems found with ineffassign
This commit is contained in:
parent
28fcc53e45
commit
740b3f6ae2
@ -67,6 +67,7 @@ func TestReadChecksum(t *testing.T) {
|
||||
_, err = fd.Seek(int64(len(b)-len(buf)), 0)
|
||||
assert.NoError(t, err)
|
||||
_, err = io.ReadFull(fd, buf)
|
||||
assert.NoError(t, err)
|
||||
// ensure we don't compare hashes
|
||||
err = fd.Close()
|
||||
assert.NoError(t, err)
|
||||
|
@ -39,7 +39,7 @@ func TestWriteFileDoubleClose(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// write to the other dup - should produce an error
|
||||
n, err = syscall.Write(fd2, buf)
|
||||
_, err = syscall.Write(fd2, buf)
|
||||
assert.Error(t, err, "input/output error")
|
||||
|
||||
// close the dup - should produce an error
|
||||
|
@ -139,7 +139,6 @@ func (fh *ReadFileHandle) Read(reqSize, reqOffset int64) (respData []byte, err e
|
||||
// file in an unchanged state.
|
||||
if reqOffset >= fh.o.Size() {
|
||||
fs.Debugf(fh.o, "ReadFileHandle.Read attempt to read beyond end of file: %d > %d", reqOffset, fh.o.Size())
|
||||
respData = nil
|
||||
return nil, nil
|
||||
}
|
||||
// Otherwise do the seek
|
||||
|
@ -689,7 +689,7 @@ func TestRandomSource(t *testing.T) {
|
||||
buf := make([]byte, 16)
|
||||
_, _ = source.Read(buf)
|
||||
sink = newRandomSource(1E8)
|
||||
n, err = io.Copy(sink, source)
|
||||
_, err = io.Copy(sink, source)
|
||||
assert.Error(t, err, "Error in stream")
|
||||
}
|
||||
|
||||
@ -966,6 +966,7 @@ func TestNewDecrypterSeek(t *testing.T) {
|
||||
|
||||
// Now try decoding it with a single open and lots of seeks
|
||||
rc, err := c.DecryptDataSeek(open, 0)
|
||||
assert.NoError(t, err)
|
||||
for _, offset := range trials {
|
||||
_, err := rc.Seek(int64(offset), 0)
|
||||
assert.NoError(t, err)
|
||||
@ -1050,6 +1051,7 @@ func TestDecrypterClose(t *testing.T) {
|
||||
// close before reading
|
||||
assert.Equal(t, nil, fh.err)
|
||||
err = fh.Close()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, ErrorFileClosed, fh.err)
|
||||
assert.Equal(t, 1, cd.closed)
|
||||
|
||||
@ -1070,6 +1072,7 @@ func TestDecrypterClose(t *testing.T) {
|
||||
assert.Equal(t, []byte{1}, out)
|
||||
assert.Equal(t, io.EOF, fh.err)
|
||||
err = fh.Close()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, ErrorFileClosed, fh.err)
|
||||
assert.Equal(t, 1, cd.closed)
|
||||
}
|
||||
|
@ -474,11 +474,9 @@ func (acc *Account) Progress() (bytes, size int64) {
|
||||
return 0, 0
|
||||
}
|
||||
acc.statmu.Lock()
|
||||
if bytes > size {
|
||||
size = 0
|
||||
}
|
||||
defer acc.statmu.Unlock()
|
||||
return acc.bytes, acc.size
|
||||
bytes, size = acc.bytes, acc.size
|
||||
acc.statmu.Unlock()
|
||||
return bytes, size
|
||||
}
|
||||
|
||||
// Speed returns the speed of the current file transfer
|
||||
@ -528,7 +526,7 @@ func (acc *Account) ETA() (eta time.Duration, ok bool) {
|
||||
// String produces stats for this file
|
||||
func (acc *Account) String() string {
|
||||
a, b := acc.Progress()
|
||||
avg, cur := acc.Speed()
|
||||
_, cur := acc.Speed()
|
||||
eta, etaok := acc.ETA()
|
||||
etas := "-"
|
||||
if etaok {
|
||||
@ -545,7 +543,7 @@ func (acc *Account) String() string {
|
||||
}
|
||||
|
||||
if Config.DataRateUnit == "bits" {
|
||||
cur, avg = cur*8, avg*8
|
||||
cur = cur * 8
|
||||
}
|
||||
|
||||
done := ""
|
||||
|
@ -472,7 +472,6 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {
|
||||
err := setConfigPassword(envpw)
|
||||
if err != nil {
|
||||
fmt.Println("Using RCLONE_CONFIG_PASS returned:", err)
|
||||
envpw = ""
|
||||
} else {
|
||||
Debugf(nil, "Using RCLONE_CONFIG_PASS password.")
|
||||
}
|
||||
|
@ -139,6 +139,9 @@ func (t *test) cleanFs() error {
|
||||
return err
|
||||
}
|
||||
dirs, err := fs.NewLister().SetLevel(1).Start(f, "").GetDirs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dir := range dirs {
|
||||
if fstest.MatchTestRemote.MatchString(dir.Name) {
|
||||
log.Printf("Purging %s%s", t.remote, dir.Name)
|
||||
|
@ -216,14 +216,14 @@ func findObject(t *testing.T, Name string) fs.Object {
|
||||
}
|
||||
|
||||
func testPut(t *testing.T, file *fstest.Item) string {
|
||||
tries := 1
|
||||
const maxTries = 10
|
||||
again:
|
||||
contents := fstest.RandomString(100)
|
||||
buf := bytes.NewBufferString(contents)
|
||||
hash := fs.NewMultiHasher()
|
||||
in := io.TeeReader(buf, hash)
|
||||
|
||||
tries := 1
|
||||
const maxTries = 10
|
||||
file.Size = int64(buf.Len())
|
||||
obji := fs.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil)
|
||||
obj, err := remote.Put(in, obji)
|
||||
@ -274,11 +274,11 @@ func TestFsPutError(t *testing.T) {
|
||||
in := io.MultiReader(buf, er)
|
||||
|
||||
obji := fs.NewStaticObjectInfo(file2.Path, file2.ModTime, 100, true, nil, nil)
|
||||
obj, err := remote.Put(in, obji)
|
||||
_, err := remote.Put(in, obji)
|
||||
// assert.Nil(t, obj) - FIXME some remotes return the object even on nil
|
||||
assert.NotNil(t, err)
|
||||
|
||||
obj, err = remote.NewObject(file2.Path)
|
||||
obj, err := remote.NewObject(file2.Path)
|
||||
assert.Nil(t, obj)
|
||||
assert.Equal(t, fs.ErrorObjectNotFound, err)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ func (f *Fs) setRoot(root string) {
|
||||
f.root = strings.Trim(root, "/")
|
||||
//Set disk root path.
|
||||
//Adding "disk:" to root path as all paths on disk start with it
|
||||
var diskRoot = ""
|
||||
var diskRoot string
|
||||
if f.root == "" {
|
||||
diskRoot = "disk:/"
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user