mirror of https://github.com/rclone/rclone.git
sftp: performance: don't consult config file outside of Fs setup
This commit is contained in:
parent
e57a388851
commit
71bc108ce6
|
@ -90,18 +90,20 @@ func init() {
|
||||||
|
|
||||||
// Fs stores the interface to the remote SFTP files
|
// Fs stores the interface to the remote SFTP files
|
||||||
type Fs struct {
|
type Fs struct {
|
||||||
name string
|
name string
|
||||||
root string
|
root string
|
||||||
features *fs.Features // optional features
|
features *fs.Features // optional features
|
||||||
config *ssh.ClientConfig
|
config *ssh.ClientConfig
|
||||||
host string
|
host string
|
||||||
port string
|
port string
|
||||||
url string
|
url string
|
||||||
mkdirLock *stringLock
|
mkdirLock *stringLock
|
||||||
cachedHashes *hash.Set
|
cachedHashes *hash.Set
|
||||||
poolMu sync.Mutex
|
hashcheckDisabled bool
|
||||||
pool []*conn
|
setModtime bool
|
||||||
connLimit *rate.Limiter // for limiting number of connections per second
|
poolMu sync.Mutex
|
||||||
|
pool []*conn
|
||||||
|
connLimit *rate.Limiter // for limiting number of connections per second
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object is a remote SFTP file that has been stat'd (so it exists, but is not necessarily open for reading)
|
// Object is a remote SFTP file that has been stat'd (so it exists, but is not necessarily open for reading)
|
||||||
|
@ -273,6 +275,8 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
pass := config.FileGet(name, "pass")
|
pass := config.FileGet(name, "pass")
|
||||||
keyFile := config.FileGet(name, "key_file")
|
keyFile := config.FileGet(name, "key_file")
|
||||||
insecureCipher := config.FileGetBool(name, "use_insecure_cipher")
|
insecureCipher := config.FileGetBool(name, "use_insecure_cipher")
|
||||||
|
hashcheckDisabled := config.FileGetBool(name, "disable_hashcheck")
|
||||||
|
setModtime := config.FileGetBool(name, "set_modtime", true)
|
||||||
if user == "" {
|
if user == "" {
|
||||||
user = currentUser
|
user = currentUser
|
||||||
}
|
}
|
||||||
|
@ -327,14 +331,16 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f := &Fs{
|
f := &Fs{
|
||||||
name: name,
|
name: name,
|
||||||
root: root,
|
root: root,
|
||||||
config: sshConfig,
|
config: sshConfig,
|
||||||
host: host,
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
url: "sftp://" + user + "@" + host + ":" + port + "/" + root,
|
url: "sftp://" + user + "@" + host + ":" + port + "/" + root,
|
||||||
mkdirLock: newStringLock(),
|
hashcheckDisabled: hashcheckDisabled,
|
||||||
connLimit: rate.NewLimiter(rate.Limit(connectionsPerSecond), 1),
|
setModtime: setModtime,
|
||||||
|
mkdirLock: newStringLock(),
|
||||||
|
connLimit: rate.NewLimiter(rate.Limit(connectionsPerSecond), 1),
|
||||||
}
|
}
|
||||||
f.features = (&fs.Features{
|
f.features = (&fs.Features{
|
||||||
CanHaveEmptyDirectories: true,
|
CanHaveEmptyDirectories: true,
|
||||||
|
@ -640,8 +646,7 @@ func (f *Fs) Hashes() hash.Set {
|
||||||
return *f.cachedHashes
|
return *f.cachedHashes
|
||||||
}
|
}
|
||||||
|
|
||||||
hashcheckDisabled := config.FileGetBool(f.name, "disable_hashcheck")
|
if f.hashcheckDisabled {
|
||||||
if hashcheckDisabled {
|
|
||||||
return hash.Set(hash.None)
|
return hash.Set(hash.None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +821,7 @@ func (o *Object) SetModTime(modTime time.Time) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "SetModTime")
|
return errors.Wrap(err, "SetModTime")
|
||||||
}
|
}
|
||||||
if config.FileGetBool(o.fs.name, "set_modtime", true) {
|
if o.fs.setModtime {
|
||||||
err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
|
err = c.sftpClient.Chtimes(o.path(), modTime, modTime)
|
||||||
o.fs.putSftpConnection(&c, err)
|
o.fs.putSftpConnection(&c, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue