"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
sftp: add --sftp-skip-links to skip symlinks and non regular files - fixes #3716
Nick Craig-Wooda7d65bd51941
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex d426b6af3..c528ee4ff 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -156,6 +156,11 @@ Home directory can be found in a shared folder called "home"Default: "",Help: "The command used to read sha1 hashes. Leave blank for autodetect.",Advanced: true,+ }, {+ Name: "skip_links",+ Default: false,+ Help: "Set to skip any symlinks and any other non regular files.",+ Advanced: true,}},}fs.Register(fsi)@@ -177,6 +182,7 @@ type Options struct {SetModTime bool `config:"set_modtime"`Md5sumCommand string `config:"md5sum_command"`Sha1sumCommand string `config:"sha1sum_command"`+ SkipLinks bool `config:"skip_links"`}// Fs stores the interface to the remote SFTP files@@ -600,12 +606,16 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err eremote := path.Join(dir, info.Name())// If file is a symlink (not a regular file is the best cross platform test we can do), do a stat to// pick up the size and type of the destination, instead of the size and type of the symlink.- if !info.Mode().IsRegular() {+ if !info.Mode().IsRegular() && !info.IsDir() {+ if f.opt.SkipLinks {+ // skip non regular file if SkipLinks is set+ continue+ }oldInfo := infoinfo, err = f.stat(remote)if err != nil {if !os.IsNotExist(err) {- fs.Errorf(remote, "stat of non-regular file/dir failed: %v", err)+ fs.Errorf(remote, "stat of non-regular file failed: %v", err)}info = oldInfo}