"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Use go-homedir to read the home directory more reliably
Nick Craig-Woodedda6d91cd78
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex 79a1f7805..c124e1eae 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -19,6 +19,7 @@ import ("sync""time"+ homedir "github.com/mitchellh/go-homedir""github.com/ncw/rclone/fs""github.com/ncw/rclone/fs/config""github.com/ncw/rclone/fs/config/configmap"@@ -322,7 +323,10 @@ func (f *Fs) putSftpConnection(pc **conn, err error) {func shellExpand(s string) string {if s != "" {if s[0] == '~' {- s = "${HOME}" + s[1:]+ newS, err := homedir.Expand(s)+ if err == nil {+ s = newS+ }}s = os.ExpandEnv(s)}diff --git a/fs/config/config.go b/fs/config/config.goindex 00ad77e99..71b91160f 100644--- a/fs/config/config.go+++ b/fs/config/config.go@@ -14,7 +14,6 @@ import ("log"mathrand "math/rand""os"- "os/user""path/filepath""regexp""runtime"@@ -25,6 +24,7 @@ import ("unicode/utf8""github.com/Unknwon/goconfig"+ homedir "github.com/mitchellh/go-homedir""github.com/ncw/rclone/fs""github.com/ncw/rclone/fs/accounting""github.com/ncw/rclone/fs/config/configmap"@@ -106,16 +106,7 @@ func getConfigData() *goconfig.ConfigFile {// Return the path to the configuration filefunc makeConfigPath() string {// Find user's home directory- usr, err := user.Current()- var homedir string- if err == nil {- homedir = usr.HomeDir- } else {- // Fall back to reading $HOME - work around user.Current() not- // working for cross compiled binaries on OSX.- // https://github.com/golang/go/issues/6376- homedir = os.Getenv("HOME")- }+ homeDir, err := homedir.Dir()// Find user's configuration directory.// Prefer XDG config path, with fallback to $HOME/.config.@@ -126,9 +117,9 @@ func makeConfigPath() string {if xdgdir != "" {// User's configuration directory for rclone is $XDG_CONFIG_HOME/rclonecfgdir = filepath.Join(xdgdir, "rclone")- } else if homedir != "" {+ } else if homeDir != "" {// User's configuration directory for rclone is $HOME/.config/rclone- cfgdir = filepath.Join(homedir, ".config", "rclone")+ cfgdir = filepath.Join(homeDir, ".config", "rclone")}// Use rclone.conf from user's configuration directory if already existing@@ -143,8 +134,8 @@ func makeConfigPath() string {// Use .rclone.conf from user's home directory if already existingvar homeconf string- if homedir != "" {- homeconf = filepath.Join(homedir, hiddenConfigFileName)+ if homeDir != "" {+ homeconf = filepath.Join(homeDir, hiddenConfigFileName)_, err := os.Stat(homeconf)if err == nil {return homeconf