rc: add config/unlock

This commit is contained in:
n4n5 2025-04-10 12:57:46 +02:00
parent 894ef3b375
commit ce57103d46
No known key found for this signature in database
GPG Key ID: 79414EADC6D4B457

View File

@ -9,6 +9,37 @@ import (
"github.com/rclone/rclone/fs/rc"
)
func init() {
rc.Add(rc.Call{
Path: "config/unlock",
Fn: rcConfigPassword,
Title: "Unlock the config file.",
AuthRequired: true,
Help: `
Unlocks the config file if it is locked.
Parameters:
- 'config_password' - password to unlock the config file
A good idea is to disable AskPassword before making this call
`,
})
}
// Unlock the config file
// A good idea is to disable AskPassword before making this call
func rcConfigPassword(ctx context.Context, in rc.Params) (out rc.Params, err error) {
configPass, err := in.GetString("config_password")
if err != nil {
return nil, err
}
if SetConfigPassword(configPass) != nil {
return nil, errors.New("failed to set config password")
}
return DumpRcBlob(), nil
}
func init() {
rc.Add(rc.Call{
Path: "config/dump",