Skip to content

Commit

Permalink
raise Exception if the provider is not webdav when using proxy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Jan 10, 2024
1 parent 608a73e commit 2278a30
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/serve/s3/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newBackend(opt *Options, w *Server) gofakes3.Backend {
}

func (b *s3Backend) getVfs(accessKey string) *vfs.VFS {
if b.opt.asProxy {
if b.opt.proxyMode {
// new VFS
if _, ok := b.w.f.(*webdav.Fs); ok {
info, name, remote, config, _ := fs.ConfigFs(b.w.f.Name() + ":")
Expand Down
11 changes: 9 additions & 2 deletions cmd/serve/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
_ "embed"

"github.com/rclone/rclone/backend/webdav"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/hash"
httplib "github.com/rclone/rclone/lib/http"
Expand All @@ -19,7 +21,7 @@ var DefaultOpt = Options{
hashName: "MD5",
hashType: hash.MD5,
noCleanup: false,
asProxy: false,
proxyMode: false,
HTTP: httplib.DefaultCfg(),
}

Expand All @@ -36,7 +38,7 @@ func init() {
flags.StringVarP(flagSet, &Opt.hashName, "etag-hash", "", Opt.hashName, "Which hash to use for the ETag, or auto or blank for off", "")
flags.StringArrayVarP(flagSet, &Opt.authPair, "auth-key", "", Opt.authPair, "Set key pair for v4 authorization: access_key_id,secret_access_key", "")
flags.BoolVarP(flagSet, &Opt.noCleanup, "no-cleanup", "", Opt.noCleanup, "Not to cleanup empty folder after object is deleted", "")
flags.BoolVarP(flagSet, &Opt.asProxy, "as-proxy", "", Opt.asProxy, "Serve as a proxy", "")
flags.BoolVarP(flagSet, &Opt.proxyMode, "proxy-mode", "", Opt.proxyMode, "Serve as a proxy for s3 clients", "")
}

//go:embed serve_s3.md
Expand All @@ -56,6 +58,11 @@ var Command = &cobra.Command{
cmd.CheckArgs(1, 1, command, args)
f := cmd.NewFsSrc(args)

if _, ok := f.(*webdav.Fs); !ok && Opt.proxyMode {
fs.Logf("serve s3", "Proxy mode is not supported for %s provider", f.Name())
return fs.ErrorNotImplemented
}

if Opt.hashName == "auto" {
Opt.hashType = f.Hashes().GetOne()
} else if Opt.hashName != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve/s3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Options struct {
hashType hash.Type
authPair []string
noCleanup bool
asProxy bool
proxyMode bool
HTTP httplib.Config
}

Expand Down

0 comments on commit 2278a30

Please sign in to comment.