forked from TrueCloudLab/rclone
Fixes from go vet and errcheck
This commit is contained in:
parent
05050d53ad
commit
2ed158aba3
7 changed files with 39 additions and 20 deletions
|
@ -71,7 +71,10 @@ func configHelper(name string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a dropbox
|
// 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.
|
// This method will ask the user to visit an URL and paste the generated code.
|
||||||
if err := db.Auth(); err != nil {
|
if err := db.Auth(); err != nil {
|
||||||
|
@ -125,7 +128,7 @@ func (f *FsDropbox) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes a new dropbox from the config
|
// Makes a new dropbox from the config
|
||||||
func newDropbox(name string) *dropbox.Dropbox {
|
func newDropbox(name string) (*dropbox.Dropbox, error) {
|
||||||
db := dropbox.NewDropbox()
|
db := dropbox.NewDropbox()
|
||||||
|
|
||||||
appKey := fs.ConfigFile.MustValue(name, "app_key")
|
appKey := fs.ConfigFile.MustValue(name, "app_key")
|
||||||
|
@ -137,9 +140,8 @@ func newDropbox(name string) *dropbox.Dropbox {
|
||||||
appSecret = fs.Reveal(rcloneAppSecret)
|
appSecret = fs.Reveal(rcloneAppSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
db.SetAppInfo(appKey, appSecret)
|
err := db.SetAppInfo(appKey, appSecret)
|
||||||
|
return db, err
|
||||||
return db
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFs contstructs an FsDropbox from the path, container:path
|
// NewFs contstructs an FsDropbox from the path, container:path
|
||||||
|
@ -147,7 +149,10 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
if uploadChunkSize > maxUploadChunkSize {
|
if uploadChunkSize > maxUploadChunkSize {
|
||||||
return nil, fmt.Errorf("Chunk size too big, must be < %v", 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{
|
f := &FsDropbox{
|
||||||
name: name,
|
name: name,
|
||||||
db: db,
|
db: db,
|
||||||
|
|
|
@ -3,9 +3,10 @@ package dropbox
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
"github.com/stacktic/dropbox"
|
"github.com/stacktic/dropbox"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NameTreeNode struct {
|
type NameTreeNode struct {
|
||||||
|
@ -135,8 +136,8 @@ func (tree *NameTreeNode) GetPathWithCorrectCase(path string) *string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result.WriteString("/")
|
_, _ = result.WriteString("/")
|
||||||
result.WriteString(current.CaseCorrectName)
|
_, _ = result.WriteString(current.CaseCorrectName)
|
||||||
}
|
}
|
||||||
|
|
||||||
resultString := result.String()
|
resultString := result.String()
|
||||||
|
|
|
@ -326,11 +326,16 @@ func PairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) {
|
||||||
err := dst.Remove()
|
err := dst.Remove()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Stats.Error()
|
Stats.Error()
|
||||||
ErrorLog(dst, "Couldn't delete: %s", err)
|
ErrorLog(dst, "Couldn't delete: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fdstMover.Move(src, src.Remote())
|
_, err := fdstMover.Move(src, src.Remote())
|
||||||
|
if err != nil {
|
||||||
|
Stats.Error()
|
||||||
|
ErrorLog(dst, "Couldn't move: %v", err)
|
||||||
|
} else {
|
||||||
Debug(src, "Moved")
|
Debug(src, "Moved")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Copy(fdst, pair.dst, src)
|
Copy(fdst, pair.dst, src)
|
||||||
}
|
}
|
||||||
|
@ -615,10 +620,12 @@ func ListFn(f Fs, fn func(Object)) error {
|
||||||
var outMutex sync.Mutex
|
var outMutex sync.Mutex
|
||||||
|
|
||||||
// Synchronized fmt.Fprintf
|
// 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()
|
outMutex.Lock()
|
||||||
defer outMutex.Unlock()
|
defer outMutex.Unlock()
|
||||||
return fmt.Fprintf(w, format, a...)
|
_, _ = fmt.Fprintf(w, format, a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List the Fs to the supplied writer
|
// List the Fs to the supplied writer
|
||||||
|
|
|
@ -121,7 +121,10 @@ func (ts *tokenSource) Token() (*oauth2.Token, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if *token != ts.OldToken {
|
if *token != ts.OldToken {
|
||||||
putToken(ts.Name, token)
|
err = putToken(ts.Name, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
|
@ -303,8 +306,8 @@ func (s *authServer) Start() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to start auth webserver: %v", err)
|
log.Fatalf("Failed to start auth webserver: %v", err)
|
||||||
}
|
}
|
||||||
server.Serve(s.listener)
|
err = server.Serve(s.listener)
|
||||||
fs.Debug(nil, "Closed auth server")
|
fs.Debug(nil, "Closed auth server with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *authServer) Stop() {
|
func (s *authServer) Stop() {
|
||||||
|
|
|
@ -205,7 +205,7 @@ func TestAmazonCloudDrivePacer(t *testing.T) {
|
||||||
got := sum / n
|
got := sum / n
|
||||||
//t.Logf("%+v: got = %v", test, got)
|
//t.Logf("%+v: got = %v", test, got)
|
||||||
if got < (test.want*9)/10 || got > (test.want*11)/10 {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,10 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to open log file: %v", err)
|
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)
|
log.SetOutput(f)
|
||||||
redirectStderr(f)
|
redirectStderr(f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ func sign(AccessKey, SecretKey string, req *http.Request) {
|
||||||
// Make signature
|
// Make signature
|
||||||
payload := req.Method + "\n" + md5 + "\n" + contentType + "\n" + date + "\n" + joinedHeadersToSign + uri
|
payload := req.Method + "\n" + md5 + "\n" + contentType + "\n" + date + "\n" + joinedHeadersToSign + uri
|
||||||
hash := hmac.New(sha1.New, []byte(SecretKey))
|
hash := hmac.New(sha1.New, []byte(SecretKey))
|
||||||
hash.Write([]byte(payload))
|
_, _ = hash.Write([]byte(payload))
|
||||||
signature := make([]byte, base64.StdEncoding.EncodedLen(hash.Size()))
|
signature := make([]byte, base64.StdEncoding.EncodedLen(hash.Size()))
|
||||||
base64.StdEncoding.Encode(signature, hash.Sum(nil))
|
base64.StdEncoding.Encode(signature, hash.Sum(nil))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue