rclone: Rework backend option parsing
This change allows passing no arguments to rclone, using `-o rclone.args=""`. It is helpful when running rclone remotely via SSH using a key with a forced command (via `command=` in `authorized_keys`).
This commit is contained in:
parent
7b8d1dc040
commit
3865b59716
3 changed files with 10 additions and 10 deletions
|
@ -127,8 +127,6 @@ func New(cfg Config, lim limiter.Limiter) (*Backend, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
args = append(args, a...)
|
args = append(args, a...)
|
||||||
} else {
|
|
||||||
args = append(args, "rclone")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// then add the arguments
|
// then add the arguments
|
||||||
|
@ -139,10 +137,6 @@ func New(cfg Config, lim limiter.Limiter) (*Backend, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, a...)
|
args = append(args, a...)
|
||||||
} else {
|
|
||||||
args = append(args,
|
|
||||||
"serve", "restic", "--stdio",
|
|
||||||
"--b2-hard-delete", "--drive-use-trash=false")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, add the remote
|
// finally, add the remote
|
||||||
|
|
|
@ -15,15 +15,19 @@ type Config struct {
|
||||||
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultConfig = Config{
|
||||||
|
Program: "rclone",
|
||||||
|
Args: "serve restic --stdio --b2-hard-delete --drive-use-trash=false",
|
||||||
|
Connections: 5,
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
options.Register("rclone", Config{})
|
options.Register("rclone", Config{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig returns a new Config with the default values filled in.
|
// NewConfig returns a new Config with the default values filled in.
|
||||||
func NewConfig() Config {
|
func NewConfig() Config {
|
||||||
return Config{
|
return defaultConfig
|
||||||
Connections: 5,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseConfig parses the string s and extracts the remote server URL.
|
// ParseConfig parses the string s and extracts the remote server URL.
|
||||||
|
|
|
@ -14,7 +14,9 @@ func TestParseConfig(t *testing.T) {
|
||||||
"rclone:local:foo:/bar",
|
"rclone:local:foo:/bar",
|
||||||
Config{
|
Config{
|
||||||
Remote: "local:foo:/bar",
|
Remote: "local:foo:/bar",
|
||||||
Connections: 5,
|
Program: defaultConfig.Program,
|
||||||
|
Args: defaultConfig.Args,
|
||||||
|
Connections: defaultConfig.Connections,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue