From 91f8894285c451dd62b3b82f757a2ecd5cb08097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Heddeland=20Instefjord?= Date: Mon, 5 Sep 2022 21:54:41 +0200 Subject: [PATCH] ftp: Add force_list_hidden option Forces the use of `LIST -a` command when listing a directory which should list all hidden folders and files. --- backend/ftp/ftp.go | 9 +++++++++ docs/content/flags.md | 1 + docs/content/ftp.md | 11 +++++++++++ go.mod | 2 +- go.sum | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index c5c885e00..b48a06eee 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -124,6 +124,11 @@ So for |concurrency 3| you'd use |--checkers 2 --transfers 2 Help: "Use MDTM to set modification time (VsFtpd quirk)", Default: false, Advanced: true, + }, { + Name: "force_list_hidden", + Help: "Use LIST -a to force listing of hidden files and folders. This will disable the use of MLSD.", + Default: false, + Advanced: true, }, { Name: "idle_timeout", Default: fs.Duration(60 * time.Second), @@ -205,6 +210,7 @@ type Options struct { DisableMLSD bool `config:"disable_mlsd"` DisableUTF8 bool `config:"disable_utf8"` WritingMDTM bool `config:"writing_mdtm"` + ForceListHidden bool `config:"force_list_hidden"` IdleTimeout fs.Duration `config:"idle_timeout"` CloseTimeout fs.Duration `config:"close_timeout"` ShutTimeout fs.Duration `config:"shut_timeout"` @@ -367,6 +373,9 @@ func (f *Fs) ftpConnection(ctx context.Context) (c *ftp.ServerConn, err error) { if f.opt.WritingMDTM { ftpConfig = append(ftpConfig, ftp.DialWithWritingMDTM(true)) } + if f.opt.ForceListHidden { + ftpConfig = append(ftpConfig, ftp.DialWithForceListHidden(true)) + } if f.ci.Dump&(fs.DumpHeaders|fs.DumpBodies|fs.DumpRequests|fs.DumpResponses) != 0 { ftpConfig = append(ftpConfig, ftp.DialWithDebugOutput(&debugLog{auth: f.ci.Dump&fs.DumpAuth != 0})) } diff --git a/docs/content/flags.md b/docs/content/flags.md index 2426a4a4a..f9753336e 100644 --- a/docs/content/flags.md +++ b/docs/content/flags.md @@ -357,6 +357,7 @@ and may be set in the config file. --ftp-tls-cache-size int Size of TLS session cache for all control and data connections (default 32) --ftp-user string FTP username (default "$USER") --ftp-writing-mdtm Use MDTM to set modification time (VsFtpd quirk) + --ftp-force-list-hidden Use LIST -a to force listing of hidden files and folders. This will disable the use of MLSD. --gcs-anonymous Access public buckets and objects without credentials --gcs-auth-url string Auth server URL --gcs-bucket-acl string Access Control List for new buckets diff --git a/docs/content/ftp.md b/docs/content/ftp.md index fa29a6821..7d4da7d7b 100644 --- a/docs/content/ftp.md +++ b/docs/content/ftp.md @@ -310,6 +310,17 @@ Properties: - Type: bool - Default: false +#### --ftp-force-list-hidden + +Use LIST -a to force listing of hidden files and folders. This will disable the use of MLSD. + +Properties: + +- Config: force_list_hidden +- Env Var: RCLONE_FTP_FORCE_LIST_HIDDEN +- Type: bool +- Default: false + #### --ftp-idle-timeout Max time before closing idle connections. diff --git a/go.mod b/go.mod index 31072dbff..6358a144c 100644 --- a/go.mod +++ b/go.mod @@ -135,7 +135,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/jlaffaye/ftp v0.0.0-20220630165035-11536801d1ff + github.com/jlaffaye/ftp v0.0.0-20220904184306-99be0634ab9a github.com/pkg/xattr v0.4.7 golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105 golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 diff --git a/go.sum b/go.sum index d09ac3566..544544307 100644 --- a/go.sum +++ b/go.sum @@ -380,6 +380,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY= github.com/jlaffaye/ftp v0.0.0-20220630165035-11536801d1ff h1:tN6UCYCBFNrPwvKf4RP9cIhGo6GcZ/IQTN8nqD7eCok= github.com/jlaffaye/ftp v0.0.0-20220630165035-11536801d1ff/go.mod h1:hhq4G4crv+nW2qXtNYcuzLeOudG92Ps37HEKeg2e3lE= +github.com/jlaffaye/ftp v0.0.0-20220904184306-99be0634ab9a h1:s4ryRQyC5HKZh6qkjNAFcvmD7gImK5bZuj/YZkXy1vw= +github.com/jlaffaye/ftp v0.0.0-20220904184306-99be0634ab9a/go.mod h1:hhq4G4crv+nW2qXtNYcuzLeOudG92Ps37HEKeg2e3lE= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=