1
mirror of https://github.com/rclone/rclone synced 2024-11-29 07:55:12 +01:00

Fixes from go vet and errcheck

This commit is contained in:
Nick Craig-Wood 2015-09-22 07:31:12 +01:00
parent 05050d53ad
commit 2ed158aba3
7 changed files with 39 additions and 20 deletions

View File

@ -71,7 +71,10 @@ func configHelper(name string) {
}
// Get a dropbox
db := newDropbox(name)
db, err := newDropbox(name)
if err != nil {
log.Fatalf("Failed to create dropbox client: %v", err)
}
// This method will ask the user to visit an URL and paste the generated code.
if err := db.Auth(); err != nil {
@ -125,7 +128,7 @@ func (f *FsDropbox) String() string {
}
// Makes a new dropbox from the config
func newDropbox(name string) *dropbox.Dropbox {
func newDropbox(name string) (*dropbox.Dropbox, error) {
db := dropbox.NewDropbox()
appKey := fs.ConfigFile.MustValue(name, "app_key")
@ -137,9 +140,8 @@ func newDropbox(name string) *dropbox.Dropbox {
appSecret = fs.Reveal(rcloneAppSecret)
}
db.SetAppInfo(appKey, appSecret)
return db
err := db.SetAppInfo(appKey, appSecret)
return db, err
}
// NewFs contstructs an FsDropbox from the path, container:path
@ -147,7 +149,10 @@ func NewFs(name, root string) (fs.Fs, error) {
if uploadChunkSize > maxUploadChunkSize {
return nil, fmt.Errorf("Chunk size too big, must be < %v", maxUploadChunkSize)
}
db := newDropbox(name)
db, err := newDropbox(name)
if err != nil {
return nil, err
}
f := &FsDropbox{
name: name,
db: db,

View File

@ -3,9 +3,10 @@ package dropbox
import (
"bytes"
"fmt"
"strings"
"github.com/ncw/rclone/fs"
"github.com/stacktic/dropbox"
"strings"
)
type NameTreeNode struct {
@ -135,8 +136,8 @@ func (tree *NameTreeNode) GetPathWithCorrectCase(path string) *string {
return nil
}
result.WriteString("/")
result.WriteString(current.CaseCorrectName)
_, _ = result.WriteString("/")
_, _ = result.WriteString(current.CaseCorrectName)
}
resultString := result.String()

View File

@ -326,11 +326,16 @@ func PairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) {
err := dst.Remove()
if err != nil {
Stats.Error()
ErrorLog(dst, "Couldn't delete: %s", err)
ErrorLog(dst, "Couldn't delete: %v", err)
}
}
fdstMover.Move(src, src.Remote())
Debug(src, "Moved")
_, err := fdstMover.Move(src, src.Remote())
if err != nil {
Stats.Error()
ErrorLog(dst, "Couldn't move: %v", err)
} else {
Debug(src, "Moved")
}
} else {
Copy(fdst, pair.dst, src)
}
@ -615,10 +620,12 @@ func ListFn(f Fs, fn func(Object)) error {
var outMutex sync.Mutex
// Synchronized fmt.Fprintf
func syncFprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
//
// Ignores errors from Fprintf
func syncFprintf(w io.Writer, format string, a ...interface{}) {
outMutex.Lock()
defer outMutex.Unlock()
return fmt.Fprintf(w, format, a...)
_, _ = fmt.Fprintf(w, format, a...)
}
// List the Fs to the supplied writer

View File

@ -121,7 +121,10 @@ func (ts *tokenSource) Token() (*oauth2.Token, error) {
return nil, err
}
if *token != ts.OldToken {
putToken(ts.Name, token)
err = putToken(ts.Name, token)
if err != nil {
return nil, err
}
}
return token, nil
}
@ -303,8 +306,8 @@ func (s *authServer) Start() {
if err != nil {
log.Fatalf("Failed to start auth webserver: %v", err)
}
server.Serve(s.listener)
fs.Debug(nil, "Closed auth server")
err = server.Serve(s.listener)
fs.Debug(nil, "Closed auth server with error: %v", err)
}
func (s *authServer) Stop() {

View File

@ -205,7 +205,7 @@ func TestAmazonCloudDrivePacer(t *testing.T) {
got := sum / n
//t.Logf("%+v: got = %v", test, got)
if got < (test.want*9)/10 || got > (test.want*11)/10 {
t.Fatalf("%+v: bad sleep want %v+/-10% got %v", test, test.want, got)
t.Fatalf("%+v: bad sleep want %v+/-10%% got %v", test, test.want, got)
}
}
}

View File

@ -356,7 +356,10 @@ func main() {
if err != nil {
log.Fatalf("Failed to open log file: %v", err)
}
f.Seek(0, os.SEEK_END)
_, err = f.Seek(0, os.SEEK_END)
if err != nil {
log.Printf("Failed to seek log file to end: %v", err)
}
log.SetOutput(f)
redirectStderr(f)
}

View File

@ -106,7 +106,7 @@ func sign(AccessKey, SecretKey string, req *http.Request) {
// Make signature
payload := req.Method + "\n" + md5 + "\n" + contentType + "\n" + date + "\n" + joinedHeadersToSign + uri
hash := hmac.New(sha1.New, []byte(SecretKey))
hash.Write([]byte(payload))
_, _ = hash.Write([]byte(payload))
signature := make([]byte, base64.StdEncoding.EncodedLen(hash.Size()))
base64.StdEncoding.Encode(signature, hash.Sum(nil))