Check triggers update if needed
(ctx context.DnoteCtx)
| 109 | |
| 110 | // Check triggers update if needed |
| 111 | func Check(ctx context.DnoteCtx) error { |
| 112 | // If upgrade check is not enabled, do not proceed further |
| 113 | if !ctx.EnableUpgradeCheck { |
| 114 | return nil |
| 115 | } |
| 116 | |
| 117 | shouldCheck, err := shouldCheckUpdate(ctx) |
| 118 | if err != nil { |
| 119 | return errors.Wrap(err, "checking if dnote should check update") |
| 120 | } |
| 121 | if !shouldCheck { |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | err = touchLastUpgrade(ctx) |
| 126 | if err != nil { |
| 127 | return errors.Wrap(err, "updating the last upgrade timestamp") |
| 128 | } |
| 129 | |
| 130 | fmt.Printf("\n") |
| 131 | willCheck, err := ui.Confirm("check for upgrade?", true) |
| 132 | if err != nil { |
| 133 | return errors.Wrap(err, "getting user confirmation") |
| 134 | } |
| 135 | if !willCheck { |
| 136 | return nil |
| 137 | } |
| 138 | |
| 139 | err = checkVersion(ctx) |
| 140 | if err != nil { |
| 141 | return errors.Wrap(err, "checking version") |
| 142 | } |
| 143 | |
| 144 | return nil |
| 145 | } |
no test coverage detected