sftp: fixup formatting and golint warnings

This commit is contained in:
Nick Craig-Wood 2017-08-07 14:50:31 +01:00
parent d025066fae
commit 74687c25f5
2 changed files with 9 additions and 5 deletions

View file

@ -9,6 +9,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"regexp"
"strings"
"time" "time"
"github.com/ncw/rclone/fs" "github.com/ncw/rclone/fs"
@ -16,8 +18,6 @@ import (
"github.com/pkg/sftp" "github.com/pkg/sftp"
"github.com/xanzy/ssh-agent" "github.com/xanzy/ssh-agent"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"strings"
"regexp"
) )
func init() { func init() {
@ -437,6 +437,7 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
return nil return nil
} }
// Hashes returns the supported hash types of the filesystem
func (f *Fs) Hashes() fs.HashSet { func (f *Fs) Hashes() fs.HashSet {
if f.cachedHashes != nil { if f.cachedHashes != nil {
return *f.cachedHashes return *f.cachedHashes
@ -461,7 +462,7 @@ func (f *Fs) Hashes() fs.HashSet {
sha1Works := parseHash(sha1Output) == expectedSha1 sha1Works := parseHash(sha1Output) == expectedSha1
md5Works := parseHash(md5Output) == expectedMd5 md5Works := parseHash(md5Output) == expectedMd5
var set fs.HashSet = fs.NewHashSet() set := fs.NewHashSet()
if !sha1Works && !md5Works { if !sha1Works && !md5Works {
set.Add(fs.HashNone) set.Add(fs.HashNone)
} }
@ -495,6 +496,8 @@ func (o *Object) Remote() string {
return o.remote return o.remote
} }
// Hash returns the selected checksum of the file
// If no checksum is available it returns ""
func (o *Object) Hash(r fs.HashType) (string, error) { func (o *Object) Hash(r fs.HashType) (string, error) {
if r == fs.HashMD5 && o.md5sum != nil { if r == fs.HashMD5 && o.md5sum != nil {
return *o.md5sum, nil return *o.md5sum, nil

View file

@ -1,9 +1,10 @@
package sftp package sftp
import ( import (
"testing"
"github.com/stretchr/testify/assert"
"fmt" "fmt"
"testing"
"github.com/stretchr/testify/assert"
) )
func TestShellEscape(t *testing.T) { func TestShellEscape(t *testing.T) {