truememory-mirror 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mirror.js +5 -6
- package/package.json +1 -1
- package/src/api-client.js +17 -2
package/bin/mirror.js
CHANGED
|
@@ -272,14 +272,13 @@ async function main() {
|
|
|
272
272
|
|
|
273
273
|
const smoothTimer = setInterval(() => {
|
|
274
274
|
if (done) return;
|
|
275
|
+
const ceiling = Math.min(serverPct + 5, 99);
|
|
275
276
|
if (displayPct < serverPct) {
|
|
276
|
-
displayPct += Math.max(0.
|
|
277
|
-
} else {
|
|
278
|
-
|
|
279
|
-
const crawl = remaining * 0.008;
|
|
280
|
-
if (crawl > 0.05) displayPct += crawl;
|
|
277
|
+
displayPct += Math.max(0.3, (serverPct - displayPct) * 0.12);
|
|
278
|
+
} else if (displayPct < ceiling) {
|
|
279
|
+
displayPct += 0.15;
|
|
281
280
|
}
|
|
282
|
-
displayPct = Math.min(displayPct,
|
|
281
|
+
displayPct = Math.min(displayPct, ceiling);
|
|
283
282
|
renderProgress();
|
|
284
283
|
}, 500);
|
|
285
284
|
|
package/package.json
CHANGED
package/src/api-client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const POLL_INTERVAL_MS = 3000;
|
|
2
|
+
const MAX_POLL_RETRIES = 3;
|
|
2
3
|
|
|
3
4
|
export async function submitForExtraction(payload, apiUrl) {
|
|
4
5
|
const body = JSON.stringify(payload);
|
|
@@ -17,12 +18,26 @@ export async function submitForExtraction(payload, apiUrl) {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export async function pollStatus(profileId, apiUrl, onUpdate) {
|
|
21
|
+
let retries = 0;
|
|
20
22
|
while (true) {
|
|
21
|
-
|
|
23
|
+
let response;
|
|
24
|
+
try {
|
|
25
|
+
response = await fetch(`${apiUrl}/api/profile/${profileId}/status`);
|
|
26
|
+
} catch {
|
|
27
|
+
retries++;
|
|
28
|
+
if (retries > MAX_POLL_RETRIES) throw new Error('Lost connection to server');
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS * 2));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
if (!response.ok) {
|
|
23
|
-
|
|
34
|
+
retries++;
|
|
35
|
+
if (retries > MAX_POLL_RETRIES) throw new Error(`Status check failed (${response.status})`);
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS * 2));
|
|
37
|
+
continue;
|
|
24
38
|
}
|
|
25
39
|
|
|
40
|
+
retries = 0;
|
|
26
41
|
const status = await response.json();
|
|
27
42
|
if (onUpdate) onUpdate(status);
|
|
28
43
|
|