2014-03-16 00:06:11 +08:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
2017-07-23 23:10:23 +08:00
|
|
|
"net"
|
2014-03-16 00:06:11 +08:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Global
|
|
|
|
var (
|
2015-09-23 01:47:16 +08:00
|
|
|
// Config is the global config
|
2018-01-13 00:30:54 +08:00
|
|
|
Config = NewConfig()
|
2014-03-16 00:06:11 +08:00
|
|
|
|
2018-01-13 00:30:54 +08:00
|
|
|
// Read a value from the config file
|
|
|
|
//
|
|
|
|
// This is a function pointer to decouple the config
|
|
|
|
// implementation from the fs
|
|
|
|
ConfigFileGet = func(section, key string, defaultVal ...string) string { return "" }
|
2017-01-03 10:52:41 +08:00
|
|
|
|
2018-01-13 00:30:54 +08: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 23:06:37 +08:00
|
|
|
|
|
|
|
// ConfigProvider is the config key used for provider options
|
|
|
|
ConfigProvider = "provider"
|
2016-08-14 19:04:43 +08:00
|
|
|
)
|
|
|
|
|
2015-09-23 01:47:16 +08:00
|
|
|
// ConfigInfo is filesystem config options
|
2014-03-16 00:06:11 +08:00
|
|
|
type ConfigInfo struct {
|
2017-09-11 14:26:53 +08:00
|
|
|
LogLevel LogLevel
|
|
|
|
StatsLogLevel LogLevel
|
|
|
|
DryRun bool
|
|
|
|
CheckSum bool
|
|
|
|
SizeOnly bool
|
|
|
|
IgnoreTimes bool
|
|
|
|
IgnoreExisting bool
|
2018-03-13 07:40:19 +08:00
|
|
|
IgnoreErrors bool
|
2017-09-11 14:26:53 +08:00
|
|
|
ModifyWindow time.Duration
|
|
|
|
Checkers int
|
|
|
|
Transfers int
|
|
|
|
ConnectTimeout time.Duration // Connect timeout
|
|
|
|
Timeout time.Duration // Data channel timeout
|
2017-11-21 04:21:44 +08:00
|
|
|
Dump DumpFlags
|
2017-09-11 14:26:53 +08:00
|
|
|
InsecureSkipVerify bool // Skip server certificate verification
|
|
|
|
DeleteMode DeleteMode
|
2018-01-23 02:53:18 +08:00
|
|
|
MaxDelete int64
|
2017-09-11 14:26:53 +08: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
|
|
|
|
NoUpdateModTime bool
|
|
|
|
DataRateUnit string
|
|
|
|
BackupDir string
|
|
|
|
Suffix string
|
|
|
|
UseListR bool
|
|
|
|
BufferSize SizeSuffix
|
2018-01-13 00:30:54 +08:00
|
|
|
BwLimit BwTimetable
|
2017-09-11 14:26:53 +08:00
|
|
|
TPSLimit float64
|
|
|
|
TPSLimitBurst int
|
|
|
|
BindAddr net.IP
|
|
|
|
DisableFeatures []string
|
2018-01-13 00:30:54 +08:00
|
|
|
UserAgent string
|
2017-09-02 16:29:01 +08:00
|
|
|
Immutable bool
|
2017-11-06 05:56:50 +08:00
|
|
|
AutoConfirm bool
|
2017-09-11 14:26:53 +08:00
|
|
|
StreamingUploadCutoff SizeSuffix
|
2018-01-11 04:32:36 +08:00
|
|
|
StatsFileNameLength int
|
2018-01-13 00:30:54 +08:00
|
|
|
AskPassword bool
|
2018-04-13 20:32:17 +08:00
|
|
|
UseServerModTime bool
|
2018-04-22 05:03:27 +08:00
|
|
|
MaxTransfer SizeSuffix
|
2018-01-13 00:30:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewConfig creates a new config with everything set to the default
|
|
|
|
// value. These are the ultimate defaults and are overriden by the
|
|
|
|
// 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-23 02:53:18 +08:00
|
|
|
c.MaxDelete = -1
|
2018-01-13 00:30:54 +08:00
|
|
|
c.LowLevelRetries = 10
|
|
|
|
c.MaxDepth = -1
|
|
|
|
c.DataRateUnit = "bytes"
|
|
|
|
c.BufferSize = SizeSuffix(16 << 20)
|
|
|
|
c.UserAgent = "rclone/" + Version
|
|
|
|
c.StreamingUploadCutoff = SizeSuffix(100 * 1024)
|
|
|
|
c.StatsFileNameLength = 40
|
|
|
|
c.AskPassword = true
|
|
|
|
c.TPSLimitBurst = 1
|
2018-04-22 05:03:27 +08:00
|
|
|
c.MaxTransfer = -1
|
2018-01-13 00:30:54 +08:00
|
|
|
|
|
|
|
return c
|
2015-05-10 18:25:54 +08:00
|
|
|
}
|