Commit 14e691b
authored
Rate-limit CLI update notices (clockworklabs#5184)
# Description of Changes
Fixes clockworklabs#5183.
This rate-limits the CLI update notice so the same advertised latest
version is printed at most once every 24 hours. It keeps the existing 24
hour release lookup cache and adds backward-compatible notice metadata
to the same cache file.
# API and ABI breaking changes
None.
# Expected complexity level and risk
1. The change is local to the lightweight update notice cache path and
only affects how often the notice is printed.
# Testing
- [x] `cargo fmt --all`
- [x] `cargo test -p spacetimedb-update update_notice`
- [x] Manual binary check with `cargo run`:
```bash
tmpdir=$(mktemp -d)
mkdir -p "$tmpdir/config"
printf '{"last_check_secs":4102444800,"latest_version":"999.0.0"}' > "$tmpdir/config/.update_check_cache"
cargo build -p spacetimedb-cli -p spacetimedb-update
SPACETIMEDB_UPDATE_MULTICALL_APPLET=spacetime cargo run -p spacetimedb-update -- --root-dir="$tmpdir" help 2> /tmp/update-notice-1.err >/tmp/update-notice-1.out
SPACETIMEDB_UPDATE_MULTICALL_APPLET=spacetime cargo run -p spacetimedb-update -- --root-dir="$tmpdir" help 2> /tmp/update-notice-2.err >/tmp/update-notice-2.out
rg "A new version of SpacetimeDB is available" /tmp/update-notice-1.err
! rg "A new version of SpacetimeDB is available" /tmp/update-notice-2.err
```
---------
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>1 parent 99b5ef6 commit 14e691b
1 file changed
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
44 | 62 | | |
45 | 63 | | |
46 | 64 | | |
| |||
78 | 96 | | |
79 | 97 | | |
80 | 98 | | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
| |||
115 | 134 | | |
116 | 135 | | |
117 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
118 | 143 | | |
119 | 144 | | |
120 | 145 | | |
121 | 146 | | |
122 | 147 | | |
123 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
124 | 216 | | |
125 | 217 | | |
0 commit comments