()
| 47 | } |
| 48 | |
| 49 | func (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 |
| 82 | func (c *CLI) walk() error { |
nothing calls this directly
no test coverage detected