MCPcopy
hub / github.com/syncthing/syncthing / Run

Method Run

cmd/syncthing/decrypt/decrypt.go:49–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func (c *CLI) Run() error {
50 log.SetFlags(0)
51
52 if c.To == "" && !c.VerifyOnly {
53 return errors.New("must set --to or --verify-only")
54 }
55
56 if c.TokenPath == "" {
57 // This is a bit long to show as default in --help
58 c.TokenPath = filepath.Join(config.DefaultMarkerName, config.EncryptionTokenName)
59 }
60
61 if c.FolderID == "" {
62 // We should try to figure out the folder ID
63 folderID, err := c.getFolderID()
64 if err != nil {
65 log.Println("No --folder-id given and couldn't read folder token")
66 return fmt.Errorf("getting folder ID: %w", err)
67 }
68
69 c.FolderID = folderID
70 if c.Verbose {
71 log.Println("Found folder ID:", c.FolderID)
72 }
73 }
74
75 c.keyGen = protocol.NewKeyGenerator()
76 c.folderKey = c.keyGen.KeyFromPassword(c.FolderID, c.Password)
77
78 return c.walk()
79}
80
81// walk finds and processes every file in the encrypted folder
82func (c *CLI) walk() error {

Callers

nothing calls this directly

Calls 5

getFolderIDMethod · 0.95
walkMethod · 0.95
NewKeyGeneratorFunction · 0.92
KeyFromPasswordMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected