forked from TrueCloudLab/restic
sftp: Return error when path starts with a tilde (~)
This commit is contained in:
parent
fae3c4d437
commit
556a63de19
1 changed files with 7 additions and 1 deletions
|
@ -64,9 +64,15 @@ func ParseConfig(s string) (interface{}, error) {
|
||||||
default:
|
default:
|
||||||
return nil, errors.New(`invalid format, does not start with "sftp:"`)
|
return nil, errors.New(`invalid format, does not start with "sftp:"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p := path.Clean(dir)
|
||||||
|
if strings.HasPrefix(p, "~") {
|
||||||
|
return nil, errors.Fatal("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory.")
|
||||||
|
}
|
||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
User: user,
|
User: user,
|
||||||
Host: host,
|
Host: host,
|
||||||
Path: path.Clean(dir),
|
Path: p,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue