MCPcopy Index your code
hub / github.com/rclone/rclone / DecryptFileName

Method DecryptFileName

backend/crypt/cipher.go:588–605  ·  view source on GitHub ↗

DecryptFileName decrypts a file path

(in string)

Source from the content-addressed store, hash-verified

586
587// DecryptFileName decrypts a file path
588func (c *Cipher) DecryptFileName(in string) (string, error) {
589 if c.mode == NameEncryptionOff {
590 remainingLength := len(in) - len(c.encryptedSuffix)
591 if remainingLength == 0 || !strings.HasSuffix(in, c.encryptedSuffix) {
592 return "", ErrorNotAnEncryptedFile
593 }
594 decrypted := in[:remainingLength]
595 if version.Match(decrypted) {
596 _, unversioned := version.Remove(decrypted)
597 if unversioned == "" {
598 return "", ErrorNotAnEncryptedFile
599 }
600 }
601 // Leave the version string on, if it was there
602 return decrypted, nil
603 }
604 return c.decryptFileName(in)
605}
606
607// DecryptDirName decrypts a directory path
608func (c *Cipher) DecryptDirName(in string) (string, error) {

Callers

nothing calls this directly

Calls 3

decryptFileNameMethod · 0.95
MatchFunction · 0.92
RemoveFunction · 0.92

Tested by

no test coverage detected