2014-03-15 16:06:11 +00:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
2017-07-23 15:10:23 +00:00
|
|
|
"net"
|
2018-05-16 15:30:09 +00:00
|
|
|
"strings"
|
2014-03-15 16:06:11 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Global
|
|
|
|
var (
|
2015-09-22 17:47:16 +00:00
|
|
|
// Config is the global config
|
2018-01-12 16:30:54 +00:00
|
|
|
Config = NewConfig()
|
2014-03-15 16:06:11 +00:00
|
|
|
|
2018-01-12 16:30:54 +00:00
|
|
|
// Read a value from the config file
|
|
|
|
//
|
|
|
|
// This is a function pointer to decouple the config
|
|
|
|
// implementation from the fs
|
2018-05-21 13:53:45 +00:00
|
|
|
ConfigFileGet = func(section, key string) (string, bool) { return "", false }
|
2017-01-03 02:52:41 +00:00
|
|
|
|
2018-05-14 17:06:57 +00:00
|
|
|
// Set a value into the config file
|
|
|
|
//
|
|
|
|
// This is a function pointer to decouple the config
|
|
|
|
// implementation from the fs
|
|
|
|
ConfigFileSet = func(section, key, value string) {
|
|
|
|
Errorf(nil, "No config handler to set %q = %q in section %q of the config file", key, value, section)
|
|
|
|
}
|
|
|
|
|
2018-01-12 16:30:54 +00:00
|
|
|
// CountError counts an error. If any errors have been
|
|
|
|
// counted then it will exit with a non zero error code.
|
|
|
|
//
|
|
|
|
// This is a function pointer to decouple the config
|
|
|
|
// implementation from the fs
|
|
|
|
CountError = func(err error) {}
|
2018-04-13 15:06:37 +00:00
|
|
|
|
|
|
|
// ConfigProvider is the config key used for provider options
|
|
|
|
ConfigProvider = "provider"
|
2016-08-14 11:04:43 +00:00
|
|
|
)
|
|
|
|
|
2015-09-22 17:47:16 +00:00
|
|
|
// ConfigInfo is filesystem config options
|
2014-03-15 16:06:11 +00:00
|
|
|
type ConfigInfo struct {
|
2017-09-11 06:26:53 +00:00
|
|
|
LogLevel LogLevel
|
|
|
|
StatsLogLevel LogLevel
|
|
|
|
DryRun bool
|
|
|
|
CheckSum bool
|
|
|
|
SizeOnly bool
|
|
|
|
IgnoreTimes bool
|
|
|
|
IgnoreExisting bool
|
2018-03-12 23:40:19 +00:00
|
|
|
IgnoreErrors bool
|
2017-09-11 06:26:53 +00:00
|
|
|
ModifyWindow time.Duration
|
|
|
|
Checkers int
|
|
|
|
Transfers int
|
|
|
|
ConnectTimeout time.Duration // Connect timeout
|
|
|
|
Timeout time.Duration // Data channel timeout
|
2017-11-20 20:21:44 +00:00
|
|
|
Dump DumpFlags
|
2017-09-11 06:26:53 +00:00
|
|
|
InsecureSkipVerify bool // Skip server certificate verification
|
|
|
|
DeleteMode DeleteMode
|
2018-01-22 18:53:18 +00:00
|
|
|
MaxDelete int64
|
2017-09-11 06:26:53 +00:00
|
|
|
TrackRenames bool // Track file renames.
|
|
|
|
LowLevelRetries int
|
|
|
|
UpdateOlder bool // Skip files that are newer on the destination
|
|
|
|
NoGzip bool // Disable compression
|
|
|
|
MaxDepth int
|
|
|
|
IgnoreSize bool
|
|
|
|
IgnoreChecksum bool
|
2018-11-25 16:49:38 +00:00
|
|
|
NoTraverse bool
|
2017-09-11 06:26:53 +00:00
|
|
|
NoUpdateModTime bool
|
|
|
|
DataRateUnit string
|
|
|
|
BackupDir string
|
|
|
|
Suffix string
|
2019-03-10 16:50:28 +00:00
|
|
|
SuffixKeepExtension bool
|
2017-09-11 06:26:53 +00:00
|
|
|
UseListR bool
|
|
|
|
BufferSize SizeSuffix
|
2018-01-12 16:30:54 +00:00
|
|
|
BwLimit BwTimetable
|
2017-09-11 06:26:53 +00:00
|
|
|
TPSLimit float64
|
|
|
|
TPSLimitBurst int
|
|
|
|
BindAddr net.IP
|
|
|
|
DisableFeatures []string
|
2018-01-12 16:30:54 +00:00
|
|
|
UserAgent string
|
2017-09-02 08:29:01 +00:00
|
|
|
Immutable bool
|
2017-11-05 21:56:50 +00:00
|
|
|
AutoConfirm bool
|
2017-09-11 06:26:53 +00:00
|
|
|
StreamingUploadCutoff SizeSuffix
|
2018-01-10 20:32:36 +00:00
|
|
|
StatsFileNameLength int
|
2018-01-12 16:30:54 +00:00
|
|
|
AskPassword bool
|
2018-04-13 12:32:17 +00:00
|
|
|
UseServerModTime bool
|
2018-04-21 21:03:27 +00:00
|
|
|
MaxTransfer SizeSuffix
|
2018-07-19 21:41:34 +00:00
|
|
|
MaxBacklog int
|
2018-08-16 15:32:35 +00:00
|
|
|
StatsOneLine bool
|
2018-06-30 15:05:31 +00:00
|
|
|
Progress bool
|
2019-01-11 17:35:29 +00:00
|
|
|
Cookie bool
|
2018-05-22 13:48:23 +00:00
|
|
|
UseMmap bool
|
2019-02-11 13:09:32 +00:00
|
|
|
CaCert string // Client Side CA
|
|
|
|
ClientCert string // Client Side Cert
|
|
|
|
ClientKey string // Client Side Key
|
2018-01-12 16:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewConfig creates a new config with everything set to the default
|
2019-04-30 12:06:24 +00:00
|
|
|
// value. These are the ultimate defaults and are overridden by the
|
2018-01-12 16:30:54 +00:00
|
|
|
// config module.
|
|
|
|
func NewConfig() *ConfigInfo {
|
|
|
|
c := new(ConfigInfo)
|
|
|
|
|
|
|
|
// Set any values which aren't the zero for the type
|
|
|
|
c.LogLevel = LogLevelNotice
|
|
|
|
c.StatsLogLevel = LogLevelInfo
|
|
|
|
c.ModifyWindow = time.Nanosecond
|
|
|
|
c.Checkers = 8
|
|
|
|
c.Transfers = 4
|
|
|
|
c.ConnectTimeout = 60 * time.Second
|
|
|
|
c.Timeout = 5 * 60 * time.Second
|
|
|
|
c.DeleteMode = DeleteModeDefault
|
2018-01-22 18:53:18 +00:00
|
|
|
c.MaxDelete = -1
|
2018-01-12 16:30:54 +00:00
|
|
|
c.LowLevelRetries = 10
|
|
|
|
c.MaxDepth = -1
|
|
|
|
c.DataRateUnit = "bytes"
|
|
|
|
c.BufferSize = SizeSuffix(16 << 20)
|
|
|
|
c.UserAgent = "rclone/" + Version
|
|
|
|
c.StreamingUploadCutoff = SizeSuffix(100 * 1024)
|
2019-01-14 16:12:39 +00:00
|
|
|
c.StatsFileNameLength = 45
|
2018-01-12 16:30:54 +00:00
|
|
|
c.AskPassword = true
|
|
|
|
c.TPSLimitBurst = 1
|
2018-04-21 21:03:27 +00:00
|
|
|
c.MaxTransfer = -1
|
2018-07-19 21:41:34 +00:00
|
|
|
c.MaxBacklog = 10000
|
2018-01-12 16:30:54 +00:00
|
|
|
|
|
|
|
return c
|
2015-05-10 10:25:54 +00:00
|
|
|
}
|
2018-05-16 15:30:09 +00:00
|
|
|
|
|
|
|
// ConfigToEnv converts an config section and name, eg ("myremote",
|
|
|
|
// "ignore-size") into an environment name
|
|
|
|
// "RCLONE_CONFIG_MYREMOTE_IGNORE_SIZE"
|
|
|
|
func ConfigToEnv(section, name string) string {
|
|
|
|
return "RCLONE_CONFIG_" + strings.ToUpper(strings.Replace(section+"_"+name, "-", "_", -1))
|
|
|
|
}
|
|
|
|
|
|
|
|
// OptionToEnv converts an option name, eg "ignore-size" into an
|
|
|
|
// environment name "RCLONE_IGNORE_SIZE"
|
|
|
|
func OptionToEnv(name string) string {
|
|
|
|
return "RCLONE_" + strings.ToUpper(strings.Replace(name, "-", "_", -1))
|
|
|
|
}
|