|
13 | 13 | * |
14 | 14 | * Contract: |
15 | 15 | * POST /k2go-api/addons/refresh -> 202 { state:"running" } |
16 | | - * GET /k2go-api/addons/refresh/status -> { state, lines, downloaded, failed } |
| 16 | + * GET /k2go-api/addons/refresh/status -> { state, lines, downloaded, reused, failed, upToDate } |
17 | 17 | * POST /k2go-api/addons/refresh/cancel -> { state:"cancelled" } |
18 | 18 | * ============================================================================ |
19 | 19 | */ |
@@ -58,12 +58,17 @@ public interface Listener { |
58 | 58 |
|
59 | 59 | /** The last status-tail line handed to the listener, so a poll that did not advance stays quiet. */ |
60 | 60 | private String lastEmitted; |
61 | | - private int lastDownloaded = -1, lastFailed = -1; |
| 61 | + private int lastDownloaded = -1, lastReused = -1, lastFailed = -1; |
| 62 | + private boolean lastUpToDate = false; |
62 | 63 |
|
63 | 64 | /** Files downloaded in the last refresh; -1 if the box did not report it. */ |
64 | 65 | public int lastDownloaded() { return lastDownloaded; } |
| 66 | + /** Files reused unchanged in the last refresh; -1 if the box did not report it (K2GO-441). */ |
| 67 | + public int lastReused() { return lastReused; } |
65 | 68 | /** Files the last refresh could not fetch or verify; -1 if the box did not report it. */ |
66 | 69 | public int lastFailed() { return lastFailed; } |
| 70 | + /** K2GO-441: true when the published set was unchanged, so the refresh downloaded nothing. */ |
| 71 | + public boolean lastUpToDate() { return lastUpToDate; } |
67 | 72 |
|
68 | 73 | /** |
69 | 74 | * Start the refresh if it is not already running, then poll to a terminal state. Each refresh is |
@@ -127,7 +132,9 @@ private String readState(@Nullable Listener l) { |
127 | 132 | if (!ok) return null; |
128 | 133 | JSONObject j = new JSONObject(text.isEmpty() ? "{}" : text); |
129 | 134 | if (j.has("downloaded")) lastDownloaded = j.optInt("downloaded", lastDownloaded); |
| 135 | + if (j.has("reused")) lastReused = j.optInt("reused", lastReused); |
130 | 136 | if (j.has("failed")) lastFailed = j.optInt("failed", lastFailed); |
| 137 | + if (j.has("upToDate")) lastUpToDate = j.optBoolean("upToDate", lastUpToDate); |
131 | 138 | if (l != null) { |
132 | 139 | JSONArray lines = j.optJSONArray("lines"); |
133 | 140 | if (lines != null && lines.length() > 0) { |
|
0 commit comments