MCPcopy
hub / github.com/rclone/rclone / Command

Method Command

backend/crypt/crypt.go:962–984  ·  view source on GitHub ↗

Command the backend to run a named command The command run is name args may be used to read arguments from opts may be used to read optional arguments from The result should be capable of being JSON encoded If it is a string or a []string it will be shown to the user otherwise it will be JSON enco

(ctx context.Context, name string, arg []string, opt map[string]string)

Source from the content-addressed store, hash-verified

960// If it is a string or a []string it will be shown to the user
961// otherwise it will be JSON encoded and shown to the user like that
962func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[string]string) (out any, err error) {
963 switch name {
964 case "decode":
965 out := make([]string, 0, len(arg))
966 for _, encryptedFileName := range arg {
967 fileName, err := f.DecryptFileName(encryptedFileName)
968 if err != nil {
969 return out, fmt.Errorf("failed to decrypt: %s: %w", encryptedFileName, err)
970 }
971 out = append(out, fileName)
972 }
973 return out, nil
974 case "encode":
975 out := make([]string, 0, len(arg))
976 for _, fileName := range arg {
977 encryptedFileName := f.EncryptFileName(fileName)
978 out = append(out, encryptedFileName)
979 }
980 return out, nil
981 default:
982 return nil, fs.ErrorCommandNotFound
983 }
984}
985
986// Object describes a wrapped for being read from the Fs
987//

Callers

nothing calls this directly

Calls 3

DecryptFileNameMethod · 0.95
EncryptFileNameMethod · 0.95
ErrorfMethod · 0.45

Tested by

no test coverage detected