Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rclone: Rework backend option parsing #2193

Merged
merged 1 commit into from Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions internal/backend/rclone/backend.go
Expand Up @@ -127,8 +127,6 @@ func New(cfg Config, lim limiter.Limiter) (*Backend, error) {
return nil, err
}
args = append(args, a...)
} else {
args = append(args, "rclone")
}

// then add the arguments
Expand All @@ -139,10 +137,6 @@ func New(cfg Config, lim limiter.Limiter) (*Backend, error) {
}

args = append(args, a...)
} else {
args = append(args,
"serve", "restic", "--stdio",
"--b2-hard-delete", "--drive-use-trash=false")
}

// finally, add the remote
Expand Down
10 changes: 7 additions & 3 deletions internal/backend/rclone/config.go
Expand Up @@ -15,15 +15,19 @@ type Config struct {
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() {
options.Register("rclone", Config{})
}

// NewConfig returns a new Config with the default values filled in.
func NewConfig() Config {
return Config{
Connections: 5,
}
return defaultConfig
}

// ParseConfig parses the string s and extracts the remote server URL.
Expand Down
4 changes: 3 additions & 1 deletion internal/backend/rclone/config_test.go
Expand Up @@ -14,7 +14,9 @@ func TestParseConfig(t *testing.T) {
"rclone:local:foo:/bar",
Config{
Remote: "local:foo:/bar",
Connections: 5,
Program: defaultConfig.Program,
Args: defaultConfig.Args,
Connections: defaultConfig.Connections,
},
},
}
Expand Down