2015-12-28 14:51:24 +00:00
|
|
|
package local
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2016-08-21 15:46:23 +00:00
|
|
|
|
2017-07-23 12:21:03 +00:00
|
|
|
"github.com/restic/restic/internal/errors"
|
|
|
|
"github.com/restic/restic/internal/options"
|
2015-12-28 14:51:24 +00:00
|
|
|
)
|
|
|
|
|
2017-03-25 12:20:03 +00:00
|
|
|
// Config holds all information needed to open a local repository.
|
|
|
|
type Config struct {
|
2017-04-02 15:57:28 +00:00
|
|
|
Path string
|
2017-04-13 21:55:32 +00:00
|
|
|
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
|
2021-08-07 17:50:00 +00:00
|
|
|
|
|
|
|
Connections uint `option:"connections" help:"set a limit for the number of concurrent operations (default: 2)"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewConfig returns a new config with default options applied.
|
|
|
|
func NewConfig() Config {
|
|
|
|
return Config{
|
|
|
|
Connections: 2,
|
|
|
|
}
|
2017-04-13 21:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
options.Register("local", Config{})
|
2017-03-25 12:20:03 +00:00
|
|
|
}
|
|
|
|
|
2015-12-28 14:51:24 +00:00
|
|
|
// ParseConfig parses a local backend config.
|
2021-08-07 17:50:00 +00:00
|
|
|
func ParseConfig(s string) (interface{}, error) {
|
|
|
|
if !strings.HasPrefix(s, "local:") {
|
2015-12-28 14:51:24 +00:00
|
|
|
return nil, errors.New(`invalid format, prefix "local" not found`)
|
|
|
|
}
|
|
|
|
|
2021-08-07 17:50:00 +00:00
|
|
|
cfg := NewConfig()
|
|
|
|
cfg.Path = s[6:]
|
|
|
|
return cfg, nil
|
2015-12-28 14:51:24 +00:00
|
|
|
}
|