querysub 0.36.0 → 0.37.0
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/package.json
CHANGED
|
@@ -41,6 +41,8 @@ let backblazeCreds = lazy((): BackblazeCreds => (
|
|
|
41
41
|
const getAPI = lazy(async () => {
|
|
42
42
|
let creds = backblazeCreds();
|
|
43
43
|
|
|
44
|
+
// NOTE: On errors, our retry code resets this lazy, so we DO get new authorize when needed.
|
|
45
|
+
// TODO: Maybe we should get new authorization periodically at well?
|
|
44
46
|
let authorizeRaw = await httpsRequest("https://api.backblazeb2.com/b2api/v2/b2_authorize_account", undefined, "GET", undefined, {
|
|
45
47
|
headers: {
|
|
46
48
|
Authorization: "Basic " + Buffer.from(creds.applicationKeyId + ":" + creds.applicationKey).toString("base64"),
|
|
@@ -65,11 +67,14 @@ const getAPI = lazy(async () => {
|
|
|
65
67
|
arg = { accountId: auth.accountId, ...arg };
|
|
66
68
|
}
|
|
67
69
|
try {
|
|
68
|
-
let
|
|
70
|
+
let url = auth.apiUrl + "/b2api/v2/" + name;
|
|
71
|
+
console.log(`Backblaze API ${type} ${url}`);
|
|
72
|
+
let result = await httpsRequest(url, Buffer.from(JSON.stringify(arg)), type, undefined, {
|
|
69
73
|
headers: {
|
|
70
74
|
Authorization: auth.authorizationToken,
|
|
71
75
|
}
|
|
72
76
|
});
|
|
77
|
+
console.log(`Finished Backblaze API ${type} ${url}`);
|
|
73
78
|
return JSON.parse(result.toString());
|
|
74
79
|
} catch (e: any) {
|
|
75
80
|
throw new Error(`Error in ${name}, arg ${JSON.stringify(arg).slice(0, 1000)}: ${e.stack}`);
|
|
@@ -479,8 +484,8 @@ class Backblaze {
|
|
|
479
484
|
await this.apiRetryLogic(async (api) => {
|
|
480
485
|
try {
|
|
481
486
|
await api.hideFile({ bucketId: this.bucketId, fileName: fileName });
|
|
482
|
-
} catch {
|
|
483
|
-
|
|
487
|
+
} catch (e: any) {
|
|
488
|
+
this.log(`backblaze error in hide, possibly already hidden ${fileName}\n${e.stack}`);
|
|
484
489
|
}
|
|
485
490
|
});
|
|
486
491
|
|
|
@@ -279,7 +279,7 @@ async function runHeartbeatAuditLoop() {
|
|
|
279
279
|
let pendingDeadCount = 0;
|
|
280
280
|
|
|
281
281
|
let removedNodeIds: string[] = [];
|
|
282
|
-
|
|
282
|
+
for (let nodeId of nodeIds) {
|
|
283
283
|
let lastTime = Number((await archives().get(nodeId))?.toString()) || 0;
|
|
284
284
|
if (lastTime < deadTime) {
|
|
285
285
|
// Increment the dead count
|
|
@@ -299,7 +299,7 @@ async function runHeartbeatAuditLoop() {
|
|
|
299
299
|
deadCount.delete(nodeId);
|
|
300
300
|
diskLog("Read node heartbeat", { nodeId, lastTime });
|
|
301
301
|
}
|
|
302
|
-
}
|
|
302
|
+
}
|
|
303
303
|
if (pendingDeadCount) {
|
|
304
304
|
console.log(blue(`Pending dead nodes ${pendingDeadCount}/${nodeIds.length}`));
|
|
305
305
|
}
|