MCPcopy
hub / github.com/syncthing/syncthing / IsEncryptedParent

Function IsEncryptedParent

lib/protocol/encryption.go:660–682  ·  view source on GitHub ↗

IsEncryptedParent returns true if the path points at a parent directory of encrypted data, i.e. is not a "real" directory. This is determined by checking for a sentinel string in the path.

(pathComponents []string)

Source from the content-addressed store, hash-verified

658// encrypted data, i.e. is not a "real" directory. This is determined by
659// checking for a sentinel string in the path.
660func IsEncryptedParent(pathComponents []string) bool {
661 l := len(pathComponents)
662 if l == 2 && len(pathComponents[1]) != 2 {
663 return false
664 } else if l == 0 {
665 return false
666 }
667 if pathComponents[0] == "" {
668 return false
669 }
670 if pathComponents[0][1:] != encryptedDirExtension {
671 return false
672 }
673 if l < 2 {
674 return true
675 }
676 for _, comp := range pathComponents[2:] {
677 if len(comp) != maxPathComponent {
678 return false
679 }
680 }
681 return true
682}
683
684type folderKeyRegistry struct {
685 keys map[string]*[keySize]byte // folder ID -> key

Callers 2

UpdateMethod · 0.92
TestIsEncryptedParentFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsEncryptedParentFunction · 0.68