@camstack/system 1.2.458 → 1.2.460
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/dist/addon-runner.js +26 -11
- package/dist/addon-runner.mjs +26 -11
- package/dist/addon-utils.mjs +1 -1
- package/dist/{agent-https-DOELEug8.js → agent-https-Dnr_nIVx.js} +3 -723
- package/dist/{agent-https-CQA3W-3e.mjs → agent-https-Iw3RSQup.mjs} +4 -616
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/dist/builtins/alerts/alerts.addon.js +5 -7
- package/dist/builtins/alerts/alerts.addon.mjs +5 -7
- package/dist/builtins/alerts/record-kinds.d.ts +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +242 -4
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +243 -5
- package/dist/builtins/calendars/calendars.addon.js +2 -10
- package/dist/builtins/calendars/calendars.addon.mjs +2 -3
- package/dist/builtins/calendars/record-kinds.d.ts +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +4 -6
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -6
- package/dist/builtins/device-history/device-history.addon.js +1 -1
- package/dist/builtins/device-history/device-history.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +2 -4
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -4
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +41 -43
- package/dist/builtins/keychain/index.mjs +41 -43
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +24 -40
- package/dist/builtins/local-auth/local-auth.addon.mjs +27 -43
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +39 -4
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +48 -13
- package/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +16 -2
- package/dist/builtins/platform-probe/coral-accelerators.d.ts +10 -1
- package/dist/builtins/platform-probe/index.js +7 -4
- package/dist/builtins/platform-probe/index.mjs +13 -10
- package/dist/builtins/platform-probe/platform-scorer.d.ts +4 -1
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/file-host-protocol.d.ts +0 -15
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +0 -44
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +0 -2
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +0 -21
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +3 -20
- package/dist/builtins/sqlite-storage/records/records-plan.d.ts +9 -4
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +4 -18
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +0 -17
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +21 -196
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +21 -196
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +6 -14
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +7 -9
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +7 -9
- package/dist/builtins/system-config/system-config.addon.js +667 -40
- package/dist/builtins/system-config/system-config.addon.mjs +737 -127
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-BVguN7VV.mjs → composition-sources-DNRZWR1j.mjs} +1 -1
- package/dist/{composition-sources-DURQNDJ4.js → composition-sources-b0e_2I-D.js} +1 -1
- package/dist/{constants-Njka8Cv6.js → constants-6OeJiZgi.js} +1 -1
- package/dist/{constants-FGjnsE2x.mjs → constants-BnkOdj9Q.mjs} +1 -1
- package/dist/{coral-accelerators-DcnZvctM.mjs → coral-accelerators-Qhn5TOYZ.mjs} +18 -15
- package/dist/{coral-accelerators-Bi_c3Rft.js → coral-accelerators-oUXmmbc2.js} +13 -10
- package/dist/{custom-action-registry-stpC3Zy-.mjs → custom-action-registry-DStvrQKI.mjs} +37 -37
- package/dist/{device-ca-lEaAQ9Xi.mjs → device-ca-Bnkw8GyU.mjs} +1 -1
- package/dist/{device-ca-BrVK_5s3.js → device-ca-CPTDs--d.js} +1 -1
- package/dist/{dist-BZQjLPiz.js → dist-Bn-RNanh.js} +29 -130
- package/dist/{dist-B_GRPhnY.mjs → dist-Wy8cTxg6.mjs} +30 -113
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-Bg2HfTwP.mjs → hub-mdns-ciao-CJu0nhla.mjs} +2 -2
- package/dist/{hub-mdns-ciao-nce3TXs_.js → hub-mdns-ciao-CTBTlia4.js} +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +56 -31
- package/dist/index.mjs +257 -233
- package/dist/kernel/deps/addon-deps-manager.d.ts +9 -0
- package/dist/{restore-archive-C7kLDI_0.mjs → restore-archive-CM23Pq9B.mjs} +177 -424
- package/dist/{restore-archive-FyfZ8YMC.js → restore-archive-DM1OBYq4.js} +89 -342
- package/dist/{wal-maintenance-Duejh7Lx.mjs → wal-maintenance-Bj_MmDkr.mjs} +0 -0
- package/dist/{wal-maintenance-DfSIOj24.js → wal-maintenance-CaJjuLHq.js} +0 -0
- package/package.json +1 -1
- package/dist/builtins/records/legacy-table-row-count.d.ts +0 -5
- package/dist/builtins/records/phase6-declare-gate.d.ts +0 -28
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +0 -5
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +0 -6
- package/dist/phase6-declare-gate-Dag1_WR2.js +0 -98
- package/dist/phase6-declare-gate-Lb-mrVvz.mjs +0 -93
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
|
|
1
|
+
import { Gi as defineRecordKinds, N as DataStoreDatabaseSchema, S as DATABASE_SNAPSHOT_SUFFIX } from "./dist-Wy8cTxg6.mjs";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createPublicKey, diffieHellman, generateKeyPairSync, hkdfSync, randomBytes } from "node:crypto";
|
|
5
4
|
import { Buffer as Buffer$1 } from "buffer";
|
|
@@ -7,8 +6,8 @@ import * as fsp from "node:fs/promises";
|
|
|
7
6
|
import jn from "node:fs/promises";
|
|
8
7
|
import * as path$1 from "node:path";
|
|
9
8
|
import path, { basename, join, posix, win32 } from "node:path";
|
|
10
|
-
import * as fs$
|
|
11
|
-
import
|
|
9
|
+
import * as fs$2 from "node:fs";
|
|
10
|
+
import fs from "node:fs";
|
|
12
11
|
import { EventEmitter } from "node:events";
|
|
13
12
|
import As, { Transform } from "node:stream";
|
|
14
13
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -21,6 +20,88 @@ import $r, { EventEmitter as EventEmitter$1 } from "events";
|
|
|
21
20
|
import * as zlib from "node:zlib";
|
|
22
21
|
import { pipeline } from "node:stream/promises";
|
|
23
22
|
import no from "node:assert";
|
|
23
|
+
var BackupScheduleBodySchema = z.object({
|
|
24
|
+
label: z.string(),
|
|
25
|
+
cron: z.string(),
|
|
26
|
+
enabled: z.boolean(),
|
|
27
|
+
locationIds: z.array(z.string()).readonly(),
|
|
28
|
+
retentionCount: z.number(),
|
|
29
|
+
dataSources: z.array(z.string()).readonly().optional(),
|
|
30
|
+
databases: z.array(DataStoreDatabaseSchema).readonly().optional(),
|
|
31
|
+
lastAttemptAt: z.number().optional(),
|
|
32
|
+
lastSuccessAt: z.number().optional(),
|
|
33
|
+
lastError: z.string().optional()
|
|
34
|
+
});
|
|
35
|
+
var BackupDestinationPolicyBodySchema = z.object({
|
|
36
|
+
enabled: z.boolean(),
|
|
37
|
+
retentionCount: z.number(),
|
|
38
|
+
label: z.string().optional(),
|
|
39
|
+
lastAttemptAt: z.number().optional(),
|
|
40
|
+
lastError: z.string().optional()
|
|
41
|
+
});
|
|
42
|
+
var BackupEncryptionKeyBodySchema = z.object({
|
|
43
|
+
keyId: z.string(),
|
|
44
|
+
publicKey: z.string(),
|
|
45
|
+
createdAt: z.number(),
|
|
46
|
+
retiredAt: z.number().nullable()
|
|
47
|
+
});
|
|
48
|
+
var BackupSeedMarkerBodySchema = z.object({ seededAt: z.number() });
|
|
49
|
+
var _backupOrchestratorRecordKinds = defineRecordKinds({
|
|
50
|
+
schedules: {
|
|
51
|
+
schema: BackupScheduleBodySchema,
|
|
52
|
+
class: "config",
|
|
53
|
+
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
54
|
+
device: "none",
|
|
55
|
+
at: "none",
|
|
56
|
+
indexes: [{
|
|
57
|
+
name: "enabled",
|
|
58
|
+
fields: ["enabled"]
|
|
59
|
+
}],
|
|
60
|
+
retention: { none: "operator delete only" },
|
|
61
|
+
entry: {
|
|
62
|
+
title: "Backup schedules",
|
|
63
|
+
nameField: "label"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"destination-policies": {
|
|
67
|
+
schema: BackupDestinationPolicyBodySchema,
|
|
68
|
+
class: "config",
|
|
69
|
+
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
70
|
+
device: "none",
|
|
71
|
+
at: "none",
|
|
72
|
+
retention: { none: "row outlives location; ensureDefault recreates" }
|
|
73
|
+
},
|
|
74
|
+
"encryption-keys": {
|
|
75
|
+
schema: BackupEncryptionKeyBodySchema,
|
|
76
|
+
class: "config",
|
|
77
|
+
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
78
|
+
device: "none",
|
|
79
|
+
at: "none",
|
|
80
|
+
retention: { none: "retired keys kept for archive decryption hints" }
|
|
81
|
+
},
|
|
82
|
+
"seed-markers": {
|
|
83
|
+
schema: BackupSeedMarkerBodySchema,
|
|
84
|
+
class: "config",
|
|
85
|
+
writeTrigger: "mark() once per seed id after seed landed",
|
|
86
|
+
device: "none",
|
|
87
|
+
at: "none",
|
|
88
|
+
retention: { none: "one row per seed id ever" }
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
92
|
+
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
93
|
+
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
94
|
+
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
95
|
+
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
96
|
+
function backupRecordStoresOf(records) {
|
|
97
|
+
return {
|
|
98
|
+
schedules: records.kind(backupSchedulesRecordKind),
|
|
99
|
+
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
100
|
+
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
101
|
+
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
24
105
|
//#region src/builtins/system-backup/backup-encryption.ts
|
|
25
106
|
/**
|
|
26
107
|
* Backup archive encryption — public key, streaming, chunked AEAD (D-backup
|
|
@@ -378,341 +459,13 @@ async function readBackupEncryptionHeader(file) {
|
|
|
378
459
|
async function decryptBackupFile(input, output, secretKey) {
|
|
379
460
|
const decrypt = createBackupDecryptStream(secretKey);
|
|
380
461
|
try {
|
|
381
|
-
await pipeline(fs$
|
|
462
|
+
await pipeline(fs$2.createReadStream(input), decrypt, fs$2.createWriteStream(output, { mode: 384 }));
|
|
382
463
|
} catch (err) {
|
|
383
464
|
await fsp.rm(output, { force: true }).catch(() => void 0);
|
|
384
465
|
throw err;
|
|
385
466
|
}
|
|
386
467
|
}
|
|
387
468
|
//#endregion
|
|
388
|
-
//#region src/builtins/backup-orchestrator/encryption-key-store.ts
|
|
389
|
-
var import_read_all_rows = require_read_all_rows();
|
|
390
|
-
/**
|
|
391
|
-
* @durable class=config owner=backup-orchestrator
|
|
392
|
-
* write="`setupEncryption` inserts one row per generated key and retires the
|
|
393
|
-
* previous active row; `disableEncryption` retires the active row"
|
|
394
|
-
* retention="none — one small row per key ever generated; a retired row
|
|
395
|
-
* names the key older archives need"
|
|
396
|
-
*/
|
|
397
|
-
var BACKUP_ENCRYPTION_KEYS_COLLECTION = "backup_encryption_keys";
|
|
398
|
-
var COLUMNS$1 = [
|
|
399
|
-
{
|
|
400
|
-
name: "key_id",
|
|
401
|
-
type: "TEXT",
|
|
402
|
-
primaryKey: true
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
name: "public_key",
|
|
406
|
-
type: "TEXT",
|
|
407
|
-
notNull: true
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: "created_at",
|
|
411
|
-
type: "INTEGER",
|
|
412
|
-
notNull: true
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: "retired_at",
|
|
416
|
-
type: "INTEGER"
|
|
417
|
-
}
|
|
418
|
-
];
|
|
419
|
-
var BackupEncryptionKeyStore = class {
|
|
420
|
-
store;
|
|
421
|
-
now;
|
|
422
|
-
declared = false;
|
|
423
|
-
keysKind;
|
|
424
|
-
constructor(store, now = Date.now, keysKind = null) {
|
|
425
|
-
this.store = store;
|
|
426
|
-
this.now = now;
|
|
427
|
-
this.keysKind = keysKind;
|
|
428
|
-
}
|
|
429
|
-
async ensureDeclared() {
|
|
430
|
-
if (this.keysKind !== null) return;
|
|
431
|
-
if (this.declared) return;
|
|
432
|
-
await this.store.declareCollection({
|
|
433
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
434
|
-
columns: COLUMNS$1
|
|
435
|
-
});
|
|
436
|
-
this.declared = true;
|
|
437
|
-
}
|
|
438
|
-
/** Every key, newest first. */
|
|
439
|
-
async list() {
|
|
440
|
-
await this.ensureDeclared();
|
|
441
|
-
const kind = this.keysKind;
|
|
442
|
-
if (kind !== null) {
|
|
443
|
-
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
444
|
-
rows.sort((a, b) => b.data.createdAt - a.data.createdAt);
|
|
445
|
-
const out = [];
|
|
446
|
-
for (const row of rows) {
|
|
447
|
-
const record = bodyToRecord(row.id, row.data);
|
|
448
|
-
if (record !== null) out.push(record);
|
|
449
|
-
}
|
|
450
|
-
return out;
|
|
451
|
-
}
|
|
452
|
-
const rows = await this.store.query({
|
|
453
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
454
|
-
filter: { orderBy: {
|
|
455
|
-
field: "created_at",
|
|
456
|
-
direction: "desc"
|
|
457
|
-
} }
|
|
458
|
-
});
|
|
459
|
-
const out = [];
|
|
460
|
-
for (const row of rows) {
|
|
461
|
-
const record = toRecord(row.data);
|
|
462
|
-
if (record !== null) out.push(record);
|
|
463
|
-
}
|
|
464
|
-
return out;
|
|
465
|
-
}
|
|
466
|
-
/** The key new archives are encrypted to; `null` = encryption off. */
|
|
467
|
-
async active() {
|
|
468
|
-
return (await this.list()).find((k) => k.retiredAt === null) ?? null;
|
|
469
|
-
}
|
|
470
|
-
/** Make `publicKey` the active key; the previous one is retired, kept listed. */
|
|
471
|
-
async activate(input) {
|
|
472
|
-
const parsed = parseBackupPublicKey(input.publicKey);
|
|
473
|
-
const t = this.now();
|
|
474
|
-
await this.retireActive(t);
|
|
475
|
-
const record = {
|
|
476
|
-
keyId: parsed.keyId,
|
|
477
|
-
publicKey: input.publicKey.trim(),
|
|
478
|
-
createdAt: t,
|
|
479
|
-
retiredAt: null
|
|
480
|
-
};
|
|
481
|
-
await this.write(record);
|
|
482
|
-
return record;
|
|
483
|
-
}
|
|
484
|
-
/** Encryption off: the active key is retired. Archives already made keep needing it. */
|
|
485
|
-
async disable() {
|
|
486
|
-
await this.retireActive(this.now());
|
|
487
|
-
}
|
|
488
|
-
async retireActive(at) {
|
|
489
|
-
for (const key of await this.list()) if (key.retiredAt === null) await this.write({
|
|
490
|
-
...key,
|
|
491
|
-
retiredAt: at
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
async write(record) {
|
|
495
|
-
await this.ensureDeclared();
|
|
496
|
-
const kind = this.keysKind;
|
|
497
|
-
if (kind !== null) {
|
|
498
|
-
const body = {
|
|
499
|
-
keyId: record.keyId,
|
|
500
|
-
publicKey: record.publicKey,
|
|
501
|
-
createdAt: record.createdAt,
|
|
502
|
-
retiredAt: record.retiredAt
|
|
503
|
-
};
|
|
504
|
-
const data = backupOrchestratorRecordKinds["encryption-keys"].schema.parse(body);
|
|
505
|
-
await kind.put({
|
|
506
|
-
id: record.keyId,
|
|
507
|
-
data
|
|
508
|
-
});
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
await this.store.deleteWhere({
|
|
512
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
513
|
-
filter: { where: { key_id: record.keyId } }
|
|
514
|
-
});
|
|
515
|
-
await this.store.insert({
|
|
516
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
517
|
-
record: {
|
|
518
|
-
id: record.keyId,
|
|
519
|
-
data: {
|
|
520
|
-
key_id: record.keyId,
|
|
521
|
-
public_key: record.publicKey,
|
|
522
|
-
created_at: record.createdAt,
|
|
523
|
-
retired_at: record.retiredAt
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
function bodyToRecord(keyId, body) {
|
|
530
|
-
if (!keyId) return null;
|
|
531
|
-
return {
|
|
532
|
-
keyId: body.keyId,
|
|
533
|
-
publicKey: body.publicKey,
|
|
534
|
-
createdAt: body.createdAt,
|
|
535
|
-
retiredAt: body.retiredAt
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
function toRecord(row) {
|
|
539
|
-
const keyId = row["key_id"];
|
|
540
|
-
const publicKey = row["public_key"];
|
|
541
|
-
const createdAt = row["created_at"];
|
|
542
|
-
if (typeof keyId !== "string" || typeof publicKey !== "string") return null;
|
|
543
|
-
const retired = row["retired_at"];
|
|
544
|
-
return {
|
|
545
|
-
keyId,
|
|
546
|
-
publicKey,
|
|
547
|
-
createdAt: typeof createdAt === "number" ? createdAt : Number(createdAt ?? 0),
|
|
548
|
-
retiredAt: typeof retired === "number" ? retired : null
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region src/builtins/backup-orchestrator/seed-marker-store.ts
|
|
553
|
-
/**
|
|
554
|
-
* @durable class=config owner=backup-orchestrator
|
|
555
|
-
* write="the orchestrator inserts one row per seed id the first time that
|
|
556
|
-
* seed is created (or found already created); never updated"
|
|
557
|
-
* retention="none — one tiny row per seed ever made; deleting it lets the
|
|
558
|
-
* seed be re-created once more on the next boot"
|
|
559
|
-
*/
|
|
560
|
-
var BACKUP_SEED_MARKERS_COLLECTION = "backup_seed_markers";
|
|
561
|
-
var COLUMNS = [{
|
|
562
|
-
name: "seed_id",
|
|
563
|
-
type: "TEXT",
|
|
564
|
-
primaryKey: true
|
|
565
|
-
}, {
|
|
566
|
-
name: "seeded_at",
|
|
567
|
-
type: "INTEGER",
|
|
568
|
-
notNull: true
|
|
569
|
-
}];
|
|
570
|
-
var BackupSeedMarkerStore = class {
|
|
571
|
-
store;
|
|
572
|
-
now;
|
|
573
|
-
declared = false;
|
|
574
|
-
markersKind;
|
|
575
|
-
constructor(store, now = Date.now, markersKind = null) {
|
|
576
|
-
this.store = store;
|
|
577
|
-
this.now = now;
|
|
578
|
-
this.markersKind = markersKind;
|
|
579
|
-
}
|
|
580
|
-
async ensureDeclared() {
|
|
581
|
-
if (this.markersKind !== null) return;
|
|
582
|
-
if (this.declared) return;
|
|
583
|
-
await this.store.declareCollection({
|
|
584
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
585
|
-
columns: COLUMNS
|
|
586
|
-
});
|
|
587
|
-
this.declared = true;
|
|
588
|
-
}
|
|
589
|
-
async has(seedId) {
|
|
590
|
-
await this.ensureDeclared();
|
|
591
|
-
const kind = this.markersKind;
|
|
592
|
-
if (kind !== null) return await kind.get(seedId) !== null;
|
|
593
|
-
return (await this.store.query({
|
|
594
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
595
|
-
filter: {
|
|
596
|
-
where: { seed_id: seedId },
|
|
597
|
-
limit: 1
|
|
598
|
-
}
|
|
599
|
-
})).length > 0;
|
|
600
|
-
}
|
|
601
|
-
async mark(seedId) {
|
|
602
|
-
await this.ensureDeclared();
|
|
603
|
-
if (await this.has(seedId)) return;
|
|
604
|
-
const kind = this.markersKind;
|
|
605
|
-
if (kind !== null) {
|
|
606
|
-
const body = { seededAt: this.now() };
|
|
607
|
-
const data = backupOrchestratorRecordKinds["seed-markers"].schema.parse(body);
|
|
608
|
-
await kind.put({
|
|
609
|
-
id: seedId,
|
|
610
|
-
data
|
|
611
|
-
});
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
await this.store.insert({
|
|
615
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
616
|
-
record: {
|
|
617
|
-
id: seedId,
|
|
618
|
-
data: {
|
|
619
|
-
seed_id: seedId,
|
|
620
|
-
seeded_at: this.now()
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
//#endregion
|
|
627
|
-
//#region src/builtins/backup-orchestrator/record-kinds.ts
|
|
628
|
-
var BACKUP_SCHEDULES_LEGACY = "backup_schedules";
|
|
629
|
-
var BACKUP_DESTINATION_POLICIES_LEGACY = "backup_destination_policies";
|
|
630
|
-
var BackupScheduleBodySchema = z.object({
|
|
631
|
-
label: z.string(),
|
|
632
|
-
cron: z.string(),
|
|
633
|
-
enabled: z.boolean(),
|
|
634
|
-
locationIds: z.array(z.string()).readonly(),
|
|
635
|
-
retentionCount: z.number(),
|
|
636
|
-
dataSources: z.array(z.string()).readonly().optional(),
|
|
637
|
-
databases: z.array(DataStoreDatabaseSchema).readonly().optional(),
|
|
638
|
-
lastAttemptAt: z.number().optional(),
|
|
639
|
-
lastSuccessAt: z.number().optional(),
|
|
640
|
-
lastError: z.string().optional()
|
|
641
|
-
});
|
|
642
|
-
var BackupDestinationPolicyBodySchema = z.object({
|
|
643
|
-
enabled: z.boolean(),
|
|
644
|
-
retentionCount: z.number(),
|
|
645
|
-
label: z.string().optional(),
|
|
646
|
-
lastAttemptAt: z.number().optional(),
|
|
647
|
-
lastError: z.string().optional()
|
|
648
|
-
});
|
|
649
|
-
var BackupEncryptionKeyBodySchema = z.object({
|
|
650
|
-
keyId: z.string(),
|
|
651
|
-
publicKey: z.string(),
|
|
652
|
-
createdAt: z.number(),
|
|
653
|
-
retiredAt: z.number().nullable()
|
|
654
|
-
});
|
|
655
|
-
var BackupSeedMarkerBodySchema = z.object({ seededAt: z.number() });
|
|
656
|
-
var _backupOrchestratorRecordKinds = defineRecordKinds({
|
|
657
|
-
schedules: {
|
|
658
|
-
schema: BackupScheduleBodySchema,
|
|
659
|
-
class: "config",
|
|
660
|
-
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
661
|
-
device: "none",
|
|
662
|
-
at: "none",
|
|
663
|
-
indexes: [{
|
|
664
|
-
name: "enabled",
|
|
665
|
-
fields: ["enabled"]
|
|
666
|
-
}],
|
|
667
|
-
retention: { none: "operator delete only" },
|
|
668
|
-
adoptsFrom: BACKUP_SCHEDULES_LEGACY,
|
|
669
|
-
entry: {
|
|
670
|
-
title: "Backup schedules",
|
|
671
|
-
nameField: "label"
|
|
672
|
-
}
|
|
673
|
-
},
|
|
674
|
-
"destination-policies": {
|
|
675
|
-
schema: BackupDestinationPolicyBodySchema,
|
|
676
|
-
class: "config",
|
|
677
|
-
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
678
|
-
device: "none",
|
|
679
|
-
at: "none",
|
|
680
|
-
retention: { none: "row outlives location; ensureDefault recreates" },
|
|
681
|
-
adoptsFrom: BACKUP_DESTINATION_POLICIES_LEGACY
|
|
682
|
-
},
|
|
683
|
-
"encryption-keys": {
|
|
684
|
-
schema: BackupEncryptionKeyBodySchema,
|
|
685
|
-
class: "config",
|
|
686
|
-
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
687
|
-
device: "none",
|
|
688
|
-
at: "none",
|
|
689
|
-
retention: { none: "retired keys kept for archive decryption hints" },
|
|
690
|
-
adoptsFrom: BACKUP_ENCRYPTION_KEYS_COLLECTION
|
|
691
|
-
},
|
|
692
|
-
"seed-markers": {
|
|
693
|
-
schema: BackupSeedMarkerBodySchema,
|
|
694
|
-
class: "config",
|
|
695
|
-
writeTrigger: "mark() once per seed id after seed landed",
|
|
696
|
-
device: "none",
|
|
697
|
-
at: "none",
|
|
698
|
-
retention: { none: "one row per seed id ever" },
|
|
699
|
-
adoptsFrom: BACKUP_SEED_MARKERS_COLLECTION
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
703
|
-
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
704
|
-
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
705
|
-
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
706
|
-
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
707
|
-
function backupRecordStoresOf(records) {
|
|
708
|
-
return {
|
|
709
|
-
schedules: records.kind(backupSchedulesRecordKind),
|
|
710
|
-
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
711
|
-
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
712
|
-
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
//#endregion
|
|
716
469
|
//#region node_modules/tar/dist/esm/index.min.js
|
|
717
470
|
var Mr = Object.defineProperty;
|
|
718
471
|
var Br = (s, t) => {
|
|
@@ -2101,15 +1854,15 @@ var An = (s) => {
|
|
|
2101
1854
|
}, In = (s) => {
|
|
2102
1855
|
let t = new st(s), e = s.file, i;
|
|
2103
1856
|
try {
|
|
2104
|
-
i =
|
|
2105
|
-
let r =
|
|
1857
|
+
i = fs.openSync(e, "r");
|
|
1858
|
+
let r = fs.fstatSync(i), n = s.maxReadSize || 16 * 1024 * 1024;
|
|
2106
1859
|
if (r.size < n) {
|
|
2107
|
-
let o = Buffer.allocUnsafe(r.size), a =
|
|
1860
|
+
let o = Buffer.allocUnsafe(r.size), a = fs.readSync(i, o, 0, r.size, 0);
|
|
2108
1861
|
t.end(a === o.byteLength ? o : o.subarray(0, a));
|
|
2109
1862
|
} else {
|
|
2110
1863
|
let o = 0, a = Buffer.allocUnsafe(n);
|
|
2111
1864
|
for (; o < r.size;) {
|
|
2112
|
-
let h =
|
|
1865
|
+
let h = fs.readSync(i, a, 0, n, o);
|
|
2113
1866
|
if (h === 0) break;
|
|
2114
1867
|
o += h, t.write(a.subarray(0, h));
|
|
2115
1868
|
}
|
|
@@ -2117,13 +1870,13 @@ var An = (s) => {
|
|
|
2117
1870
|
}
|
|
2118
1871
|
} finally {
|
|
2119
1872
|
if (typeof i == "number") try {
|
|
2120
|
-
|
|
1873
|
+
fs.closeSync(i);
|
|
2121
1874
|
} catch {}
|
|
2122
1875
|
}
|
|
2123
1876
|
}, Fn = (s, t) => {
|
|
2124
1877
|
let e = new st(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
2125
1878
|
return new Promise((o, a) => {
|
|
2126
|
-
e.on("error", a), e.on("end", o),
|
|
1879
|
+
e.on("error", a), e.on("end", o), fs.stat(r, (h, l) => {
|
|
2127
1880
|
if (h) a(h);
|
|
2128
1881
|
else {
|
|
2129
1882
|
let c = new _t(r, {
|
|
@@ -2644,7 +2397,7 @@ var mi = class {
|
|
|
2644
2397
|
constructor(t, e) {
|
|
2645
2398
|
this.path = t || "./", this.absolute = e;
|
|
2646
2399
|
}
|
|
2647
|
-
}, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs = Symbol("readdir"), ci = Symbol("onreaddir"), fi = Symbol("pipe"), rr = Symbol("entry"), as = Symbol("entryOpt"), di = Symbol("writeEntryClass"), or = Symbol("write"), ls = Symbol("ondrain"), wt = class extends A {
|
|
2400
|
+
}, ir = Buffer.alloc(1024), ai = Symbol("onStat"), ue = Symbol("ended"), W = Symbol("queue"), me = Symbol("pendingLinks"), Et = Symbol("current"), Ct = Symbol("process"), pe = Symbol("processing"), hi = Symbol("processJob"), G = Symbol("jobs"), hs = Symbol("jobDone"), li = Symbol("addFSEntry"), sr = Symbol("addTarEntry"), cs = Symbol("stat"), fs$1 = Symbol("readdir"), ci = Symbol("onreaddir"), fi = Symbol("pipe"), rr = Symbol("entry"), as = Symbol("entryOpt"), di = Symbol("writeEntryClass"), or = Symbol("write"), ls = Symbol("ondrain"), wt = class extends A {
|
|
2648
2401
|
sync = !1;
|
|
2649
2402
|
opt;
|
|
2650
2403
|
cwd;
|
|
@@ -2722,7 +2475,7 @@ var mi = class {
|
|
|
2722
2475
|
}
|
|
2723
2476
|
this[Ct]();
|
|
2724
2477
|
}
|
|
2725
|
-
[fs](t) {
|
|
2478
|
+
[fs$1](t) {
|
|
2726
2479
|
t.pending = !0, this[G] += 1, I.readdir(t.absolute, (e, i) => {
|
|
2727
2480
|
if (t.pending = !1, this[G] -= 1, e) return this.emit("error", e);
|
|
2728
2481
|
this[ci](t, i);
|
|
@@ -2769,7 +2522,7 @@ var mi = class {
|
|
|
2769
2522
|
if (t.stat && !t.ignore) {
|
|
2770
2523
|
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2771
2524
|
let e = this.readdirCache.get(t.absolute);
|
|
2772
|
-
if (e ? this[ci](t, e) : this[fs](t), !t.readdir) return;
|
|
2525
|
+
if (e ? this[ci](t, e) : this[fs$1](t), !t.readdir) return;
|
|
2773
2526
|
}
|
|
2774
2527
|
if (t.entry = this[rr](t), !t.entry) {
|
|
2775
2528
|
t.ignore = !0;
|
|
@@ -2838,7 +2591,7 @@ var mi = class {
|
|
|
2838
2591
|
let e = this.follow ? "statSync" : "lstatSync";
|
|
2839
2592
|
this[ai](t, I[e](t.absolute));
|
|
2840
2593
|
}
|
|
2841
|
-
[fs](t) {
|
|
2594
|
+
[fs$1](t) {
|
|
2842
2595
|
this[ci](t, I.readdirSync(t.absolute));
|
|
2843
2596
|
}
|
|
2844
2597
|
[fi](t) {
|
|
@@ -2894,12 +2647,12 @@ var Wn = (s, t) => {
|
|
|
2894
2647
|
var ur = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: mr, O_NOFOLLOW: cr, O_TRUNC: pr, O_WRONLY: Er } = I.constants, wr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, $n = ur && !!wr, Xn = 512 * 1024, qn = wr | pr | mr | Er, fr = !ur && typeof cr == "number" ? cr | pr | mr | Er : null, ds = fr !== null ? () => fr : $n ? (s) => s < Xn ? qn : "w" : () => "w";
|
|
2895
2648
|
var us = (s, t, e) => {
|
|
2896
2649
|
try {
|
|
2897
|
-
return
|
|
2650
|
+
return fs.lchownSync(s, t, e);
|
|
2898
2651
|
} catch (i) {
|
|
2899
2652
|
if (i?.code !== "ENOENT") throw i;
|
|
2900
2653
|
}
|
|
2901
2654
|
}, pi = (s, t, e, i) => {
|
|
2902
|
-
|
|
2655
|
+
fs.lchown(s, t, e, (r) => {
|
|
2903
2656
|
i(r && r?.code !== "ENOENT" ? r : null);
|
|
2904
2657
|
});
|
|
2905
2658
|
}, Qn = (s, t, e, i, r) => {
|
|
@@ -2909,7 +2662,7 @@ var us = (s, t, e) => {
|
|
|
2909
2662
|
});
|
|
2910
2663
|
else pi(path.resolve(s, t.name), e, i, r);
|
|
2911
2664
|
}, ms = (s, t, e, i) => {
|
|
2912
|
-
|
|
2665
|
+
fs.readdir(s, { withFileTypes: !0 }, (r, n) => {
|
|
2913
2666
|
if (r) {
|
|
2914
2667
|
if (r.code === "ENOENT") return i();
|
|
2915
2668
|
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
@@ -2928,7 +2681,7 @@ var us = (s, t, e) => {
|
|
|
2928
2681
|
}, ps = (s, t, e) => {
|
|
2929
2682
|
let i;
|
|
2930
2683
|
try {
|
|
2931
|
-
i =
|
|
2684
|
+
i = fs.readdirSync(s, { withFileTypes: !0 });
|
|
2932
2685
|
} catch (r) {
|
|
2933
2686
|
let n = r;
|
|
2934
2687
|
if (n?.code === "ENOENT") return;
|
|
@@ -2962,13 +2715,13 @@ var St = class extends Error {
|
|
|
2962
2715
|
}
|
|
2963
2716
|
};
|
|
2964
2717
|
var to = (s, t) => {
|
|
2965
|
-
|
|
2718
|
+
fs.stat(s, (e, i) => {
|
|
2966
2719
|
(e || !i.isDirectory()) && (e = new we(s, e?.code || "ENOTDIR")), t(e);
|
|
2967
2720
|
});
|
|
2968
2721
|
}, Sr = (s, t, e) => {
|
|
2969
2722
|
s = f(s);
|
|
2970
2723
|
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, a = t.gid, h = typeof o == "number" && typeof a == "number" && (o !== t.processUid || a !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), S = (E, x) => {
|
|
2971
|
-
E ? e(E) : x && h ? ms(x, o, a, (xe) => S(xe)) : n ?
|
|
2724
|
+
E ? e(E) : x && h ? ms(x, o, a, (xe) => S(xe)) : n ? fs.chmod(s, r, e) : e();
|
|
2972
2725
|
};
|
|
2973
2726
|
if (s === d) return to(s, S);
|
|
2974
2727
|
if (l) return jn.mkdir(s, {
|
|
@@ -2979,14 +2732,14 @@ var to = (s, t) => {
|
|
|
2979
2732
|
}, Es = (s, t, e, i, r, n, o) => {
|
|
2980
2733
|
if (t.length === 0) return o(null, n);
|
|
2981
2734
|
let a = t.shift(), h = f(path.resolve(s + "/" + a));
|
|
2982
|
-
|
|
2735
|
+
fs.mkdir(h, e, yr(h, t, e, i, r, n, o));
|
|
2983
2736
|
}, yr = (s, t, e, i, r, n, o) => (a) => {
|
|
2984
|
-
a ?
|
|
2737
|
+
a ? fs.lstat(s, (h, l) => {
|
|
2985
2738
|
if (h) h.path = h.path && f(h.path), o(h);
|
|
2986
2739
|
else if (l.isDirectory()) Es(s, t, e, i, r, n, o);
|
|
2987
|
-
else if (i)
|
|
2740
|
+
else if (i) fs.unlink(s, (c) => {
|
|
2988
2741
|
if (c) return o(c);
|
|
2989
|
-
|
|
2742
|
+
fs.mkdir(s, e, yr(s, t, e, i, r, n, o));
|
|
2990
2743
|
});
|
|
2991
2744
|
else {
|
|
2992
2745
|
if (l.isSymbolicLink()) return o(new St(s, s + "/" + t.join("/")));
|
|
@@ -2996,7 +2749,7 @@ var to = (s, t) => {
|
|
|
2996
2749
|
}, eo = (s) => {
|
|
2997
2750
|
let t = !1, e;
|
|
2998
2751
|
try {
|
|
2999
|
-
t =
|
|
2752
|
+
t = fs.statSync(s).isDirectory();
|
|
3000
2753
|
} catch (i) {
|
|
3001
2754
|
e = i?.code;
|
|
3002
2755
|
} finally {
|
|
@@ -3005,10 +2758,10 @@ var to = (s, t) => {
|
|
|
3005
2758
|
}, Rr = (s, t) => {
|
|
3006
2759
|
s = f(s);
|
|
3007
2760
|
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, a = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), h = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
3008
|
-
E && a && ps(E, n, o), r &&
|
|
2761
|
+
E && a && ps(E, n, o), r && fs.chmodSync(s, i);
|
|
3009
2762
|
};
|
|
3010
2763
|
if (s === c) return eo(c), d();
|
|
3011
|
-
if (h) return d(
|
|
2764
|
+
if (h) return d(fs.mkdirSync(s, {
|
|
3012
2765
|
mode: i,
|
|
3013
2766
|
recursive: !0
|
|
3014
2767
|
}) ?? void 0);
|
|
@@ -3016,12 +2769,12 @@ var to = (s, t) => {
|
|
|
3016
2769
|
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
3017
2770
|
x = f(path.resolve(x));
|
|
3018
2771
|
try {
|
|
3019
|
-
|
|
2772
|
+
fs.mkdirSync(x, i), N = N || x;
|
|
3020
2773
|
} catch {
|
|
3021
|
-
let xe =
|
|
2774
|
+
let xe = fs.lstatSync(x);
|
|
3022
2775
|
if (xe.isDirectory()) continue;
|
|
3023
2776
|
if (l) {
|
|
3024
|
-
|
|
2777
|
+
fs.unlinkSync(x), fs.mkdirSync(x, i), N = N || x;
|
|
3025
2778
|
continue;
|
|
3026
2779
|
} else if (xe.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
|
|
3027
2780
|
}
|
|
@@ -3111,16 +2864,16 @@ var so = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32"
|
|
|
3111
2864
|
};
|
|
3112
2865
|
var Or = () => process.umask();
|
|
3113
2866
|
var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs = Symbol("isReusable"), P = Symbol("makeFs"), _s = Symbol("file"), Os = Symbol("directory"), Ri = Symbol("link"), Lr = Symbol("symlink"), Nr = Symbol("hardlink"), ye = Symbol("ensureNoSymlink"), Dr = Symbol("unsupported"), Ar = Symbol("checkPath"), Ss = Symbol("stripAbsolutePath"), yt = Symbol("mkdir"), O = Symbol("onError"), yi = Symbol("pending"), Ir = Symbol("pend"), $t = Symbol("unpend"), ys = Symbol("ended"), Rs = Symbol("maybeClose"), Ts = Symbol("skip"), Re = Symbol("doChown"), ge = Symbol("uid"), be = Symbol("gid"), _e = Symbol("checkedCwd"), Oe = (process.env.TESTING_TAR_FAKE_PLATFORM || process.platform) === "win32", ho = 1024, ao = (s, t) => {
|
|
3114
|
-
if (!Oe) return
|
|
2867
|
+
if (!Oe) return fs.unlink(s, t);
|
|
3115
2868
|
let e = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
3116
|
-
|
|
2869
|
+
fs.rename(s, e, (i) => {
|
|
3117
2870
|
if (i) return t(i);
|
|
3118
|
-
|
|
2871
|
+
fs.unlink(e, t);
|
|
3119
2872
|
});
|
|
3120
2873
|
}, lo = (s) => {
|
|
3121
|
-
if (!Oe) return
|
|
2874
|
+
if (!Oe) return fs.unlinkSync(s);
|
|
3122
2875
|
let t = s + ".DELETE." + randomBytes(16).toString("hex");
|
|
3123
|
-
|
|
2876
|
+
fs.renameSync(s, t), fs.unlinkSync(t);
|
|
3124
2877
|
}, Fr = (s, t, e) => s !== void 0 && s === s >>> 0 ? s : t !== void 0 && t === t >>> 0 ? t : e, Xt = class extends st {
|
|
3125
2878
|
[ys] = !1;
|
|
3126
2879
|
[_e] = !1;
|
|
@@ -3264,14 +3017,14 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3264
3017
|
autoClose: !1
|
|
3265
3018
|
});
|
|
3266
3019
|
r.on("error", (h) => {
|
|
3267
|
-
r.fd &&
|
|
3020
|
+
r.fd && fs.close(r.fd, () => {}), r.write = () => !0, this[O](h, t), e();
|
|
3268
3021
|
});
|
|
3269
3022
|
let n = 1, o = (h) => {
|
|
3270
3023
|
if (h) {
|
|
3271
|
-
r.fd &&
|
|
3024
|
+
r.fd && fs.close(r.fd, () => {}), this[O](h, t), e();
|
|
3272
3025
|
return;
|
|
3273
3026
|
}
|
|
3274
|
-
--n === 0 && r.fd !== void 0 &&
|
|
3027
|
+
--n === 0 && r.fd !== void 0 && fs.close(r.fd, (l) => {
|
|
3275
3028
|
l ? this[O](l, t) : this[$t](), e();
|
|
3276
3029
|
});
|
|
3277
3030
|
};
|
|
@@ -3280,12 +3033,12 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3280
3033
|
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
3281
3034
|
n++;
|
|
3282
3035
|
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
3283
|
-
|
|
3036
|
+
fs.futimes(l, c, d, (S) => S ? fs.utimes(h, c, d, (T) => o(T && S)) : o());
|
|
3284
3037
|
}
|
|
3285
3038
|
if (typeof l == "number" && this[Re](t)) {
|
|
3286
3039
|
n++;
|
|
3287
3040
|
let c = this[ge](t), d = this[be](t);
|
|
3288
|
-
typeof c == "number" && typeof d == "number" &&
|
|
3041
|
+
typeof c == "number" && typeof d == "number" && fs.fchown(l, c, d, (S) => S ? fs.chown(h, c, d, (T) => o(T && S)) : o());
|
|
3289
3042
|
}
|
|
3290
3043
|
o();
|
|
3291
3044
|
});
|
|
@@ -3304,7 +3057,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3304
3057
|
let n = 1, o = () => {
|
|
3305
3058
|
--n === 0 && (e(), this[$t](), t.resume());
|
|
3306
3059
|
};
|
|
3307
|
-
t.mtime && !this.noMtime && (n++,
|
|
3060
|
+
t.mtime && !this.noMtime && (n++, fs.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[Re](t) && (n++, fs.chown(String(t.absolute), Number(this[ge](t)), Number(this[be](t)), o)), o();
|
|
3308
3061
|
});
|
|
3309
3062
|
}
|
|
3310
3063
|
[Dr](t) {
|
|
@@ -3326,7 +3079,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3326
3079
|
let o = i.shift();
|
|
3327
3080
|
if (this.preservePaths || o === void 0) return r();
|
|
3328
3081
|
let a = path.resolve(e, o);
|
|
3329
|
-
|
|
3082
|
+
fs.lstat(a, (h, l) => {
|
|
3330
3083
|
if (h) return r();
|
|
3331
3084
|
if (l?.isSymbolicLink()) return n(new St(a, path.resolve(a, i.join("/"))));
|
|
3332
3085
|
this[ye](t, a, i, r, n);
|
|
@@ -3373,7 +3126,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3373
3126
|
}
|
|
3374
3127
|
o();
|
|
3375
3128
|
}, o = () => {
|
|
3376
|
-
|
|
3129
|
+
fs.lstat(String(t.absolute), (a, h) => {
|
|
3377
3130
|
if (h && (this.keep || this.newer && h.mtime > (t.mtime ?? h.mtime))) {
|
|
3378
3131
|
this[Ts](t), i();
|
|
3379
3132
|
return;
|
|
@@ -3382,9 +3135,9 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3382
3135
|
if (h.isDirectory()) {
|
|
3383
3136
|
if (t.type === "Directory") {
|
|
3384
3137
|
let l = this.chmod && t.mode && (h.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
3385
|
-
return l ?
|
|
3138
|
+
return l ? fs.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
3386
3139
|
}
|
|
3387
|
-
if (t.absolute !== this.cwd) return
|
|
3140
|
+
if (t.absolute !== this.cwd) return fs.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
3388
3141
|
}
|
|
3389
3142
|
if (t.absolute === this.cwd) return this[P](null, t, i);
|
|
3390
3143
|
ao(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
@@ -3408,7 +3161,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3408
3161
|
}
|
|
3409
3162
|
}
|
|
3410
3163
|
[Ri](t, e, i, r) {
|
|
3411
|
-
|
|
3164
|
+
fs[i](e, String(t.absolute), (n) => {
|
|
3412
3165
|
n ? this[O](n, t) : (this[$t](), t.resume()), r();
|
|
3413
3166
|
});
|
|
3414
3167
|
}
|
|
@@ -3436,17 +3189,17 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3436
3189
|
if (o) return this[O](o, t);
|
|
3437
3190
|
}
|
|
3438
3191
|
}
|
|
3439
|
-
let [e, i] = Se(() =>
|
|
3192
|
+
let [e, i] = Se(() => fs.lstatSync(String(t.absolute)));
|
|
3440
3193
|
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ts](t);
|
|
3441
3194
|
if (e || this[bs](t, i)) return this[P](null, t);
|
|
3442
3195
|
if (i.isDirectory()) {
|
|
3443
3196
|
if (t.type === "Directory") {
|
|
3444
3197
|
let [a] = this.chmod && t.mode && (i.mode & 4095) !== t.mode ? Se(() => {
|
|
3445
|
-
|
|
3198
|
+
fs.chmodSync(String(t.absolute), Number(t.mode));
|
|
3446
3199
|
}) : [];
|
|
3447
3200
|
return this[P](a, t);
|
|
3448
3201
|
}
|
|
3449
|
-
let [n] = Se(() =>
|
|
3202
|
+
let [n] = Se(() => fs.rmdirSync(String(t.absolute)));
|
|
3450
3203
|
this[P](n, t);
|
|
3451
3204
|
}
|
|
3452
3205
|
let [r] = t.absolute === this.cwd ? [] : Se(() => lo(String(t.absolute)));
|
|
@@ -3456,21 +3209,21 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3456
3209
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (a) => {
|
|
3457
3210
|
let h;
|
|
3458
3211
|
try {
|
|
3459
|
-
|
|
3212
|
+
fs.closeSync(n);
|
|
3460
3213
|
} catch (l) {
|
|
3461
3214
|
h = l;
|
|
3462
3215
|
}
|
|
3463
3216
|
(a || h) && this[O](a || h, t), e();
|
|
3464
3217
|
}, n;
|
|
3465
3218
|
try {
|
|
3466
|
-
n =
|
|
3219
|
+
n = fs.openSync(String(t.absolute), ds(t.size), i);
|
|
3467
3220
|
} catch (a) {
|
|
3468
3221
|
return r(a);
|
|
3469
3222
|
}
|
|
3470
3223
|
let o = this.transform && this.transform(t) || t;
|
|
3471
3224
|
o !== t && (o.on("error", (a) => this[O](a, t)), t.pipe(o)), o.on("data", (a) => {
|
|
3472
3225
|
try {
|
|
3473
|
-
|
|
3226
|
+
fs.writeSync(n, a, 0, a.length);
|
|
3474
3227
|
} catch (h) {
|
|
3475
3228
|
r(h);
|
|
3476
3229
|
}
|
|
@@ -3479,10 +3232,10 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3479
3232
|
if (t.mtime && !this.noMtime) {
|
|
3480
3233
|
let h = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
3481
3234
|
try {
|
|
3482
|
-
|
|
3235
|
+
fs.futimesSync(n, h, l);
|
|
3483
3236
|
} catch (c) {
|
|
3484
3237
|
try {
|
|
3485
|
-
|
|
3238
|
+
fs.utimesSync(String(t.absolute), h, l);
|
|
3486
3239
|
} catch {
|
|
3487
3240
|
a = c;
|
|
3488
3241
|
}
|
|
@@ -3491,10 +3244,10 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3491
3244
|
if (this[Re](t)) {
|
|
3492
3245
|
let h = this[ge](t), l = this[be](t);
|
|
3493
3246
|
try {
|
|
3494
|
-
|
|
3247
|
+
fs.fchownSync(n, Number(h), Number(l));
|
|
3495
3248
|
} catch (c) {
|
|
3496
3249
|
try {
|
|
3497
|
-
|
|
3250
|
+
fs.chownSync(String(t.absolute), Number(h), Number(l));
|
|
3498
3251
|
} catch {
|
|
3499
3252
|
a = a || c;
|
|
3500
3253
|
}
|
|
@@ -3510,10 +3263,10 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3510
3263
|
return;
|
|
3511
3264
|
}
|
|
3512
3265
|
if (t.mtime && !this.noMtime) try {
|
|
3513
|
-
|
|
3266
|
+
fs.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
3514
3267
|
} catch {}
|
|
3515
3268
|
if (this[Re](t)) try {
|
|
3516
|
-
|
|
3269
|
+
fs.chownSync(String(t.absolute), Number(this[ge](t)), Number(this[be](t)));
|
|
3517
3270
|
} catch {}
|
|
3518
3271
|
e(), t.resume();
|
|
3519
3272
|
}
|
|
@@ -3539,7 +3292,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3539
3292
|
let o = e;
|
|
3540
3293
|
for (let a of i) {
|
|
3541
3294
|
o = path.resolve(o, a);
|
|
3542
|
-
let [h, l] = Se(() =>
|
|
3295
|
+
let [h, l] = Se(() => fs.lstatSync(o));
|
|
3543
3296
|
if (h) return r();
|
|
3544
3297
|
if (l.isSymbolicLink()) return n(new St(o, path.resolve(e, i.join("/"))));
|
|
3545
3298
|
}
|
|
@@ -3548,13 +3301,13 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3548
3301
|
[Ri](t, e, i, r) {
|
|
3549
3302
|
let n = `${i}Sync`;
|
|
3550
3303
|
try {
|
|
3551
|
-
|
|
3304
|
+
fs[n](e, String(t.absolute)), r(), t.resume();
|
|
3552
3305
|
} catch (o) {
|
|
3553
3306
|
return this[O](o, t);
|
|
3554
3307
|
}
|
|
3555
3308
|
}
|
|
3556
3309
|
}, co = (s) => {
|
|
3557
|
-
let t = new Te(s), e = s.file, i =
|
|
3310
|
+
let t = new Te(s), e = s.file, i = fs.statSync(e);
|
|
3558
3311
|
new Me(e, {
|
|
3559
3312
|
readSize: s.maxReadSize || 16 * 1024 * 1024,
|
|
3560
3313
|
size: i.size
|
|
@@ -3562,7 +3315,7 @@ var Tr = Symbol("onEntry"), gs = Symbol("checkFs"), xr = Symbol("checkFs2"), bs
|
|
|
3562
3315
|
}, fo = (s, t) => {
|
|
3563
3316
|
let e = new Xt(s), i = s.maxReadSize || 16 * 1024 * 1024, r = s.file;
|
|
3564
3317
|
return new Promise((o, a) => {
|
|
3565
|
-
e.on("error", a), e.on("close", o),
|
|
3318
|
+
e.on("error", a), e.on("close", o), fs.stat(r, (h, l) => {
|
|
3566
3319
|
if (h) a(h);
|
|
3567
3320
|
else {
|
|
3568
3321
|
let c = new _t(r, {
|
|
@@ -3581,15 +3334,15 @@ var mo = (s, t) => {
|
|
|
3581
3334
|
let e = new kt(s), i = !0, r, n;
|
|
3582
3335
|
try {
|
|
3583
3336
|
try {
|
|
3584
|
-
r =
|
|
3337
|
+
r = fs.openSync(s.file, "r+");
|
|
3585
3338
|
} catch (h) {
|
|
3586
|
-
if (h?.code === "ENOENT") r =
|
|
3339
|
+
if (h?.code === "ENOENT") r = fs.openSync(s.file, "w+");
|
|
3587
3340
|
else throw h;
|
|
3588
3341
|
}
|
|
3589
|
-
let o =
|
|
3342
|
+
let o = fs.fstatSync(r), a = Buffer.alloc(512);
|
|
3590
3343
|
t: for (n = 0; n < o.size; n += 512) {
|
|
3591
3344
|
for (let c = 0, d = 0; c < 512; c += d) {
|
|
3592
|
-
if (d =
|
|
3345
|
+
if (d = fs.readSync(r, a, c, a.length - c, n + c), n === 0 && a[0] === 31 && a[1] === 139) throw new Error("cannot append to compressed archives");
|
|
3593
3346
|
if (!d) break t;
|
|
3594
3347
|
}
|
|
3595
3348
|
let h = new C(a);
|
|
@@ -3601,7 +3354,7 @@ var mo = (s, t) => {
|
|
|
3601
3354
|
i = !1, po(s, e, n, r, t);
|
|
3602
3355
|
} finally {
|
|
3603
3356
|
if (i) try {
|
|
3604
|
-
|
|
3357
|
+
fs.closeSync(r);
|
|
3605
3358
|
} catch {}
|
|
3606
3359
|
}
|
|
3607
3360
|
}, po = (s, t, e, i, r) => {
|
|
@@ -3614,29 +3367,29 @@ var mo = (s, t) => {
|
|
|
3614
3367
|
t = Array.from(t);
|
|
3615
3368
|
let e = new wt(s), i = (n, o, a) => {
|
|
3616
3369
|
let h = (T, N) => {
|
|
3617
|
-
T ?
|
|
3370
|
+
T ? fs.close(n, (E) => a(T)) : a(null, N);
|
|
3618
3371
|
}, l = 0;
|
|
3619
3372
|
if (o === 0) return h(null, 0);
|
|
3620
3373
|
let c = 0, d = Buffer.alloc(512), S = (T, N) => {
|
|
3621
3374
|
if (T || N === void 0) return h(T);
|
|
3622
|
-
if (c += N, c < 512 && N) return
|
|
3375
|
+
if (c += N, c < 512 && N) return fs.read(n, d, c, d.length - c, l + c, S);
|
|
3623
3376
|
if (l === 0 && d[0] === 31 && d[1] === 139) return h(/* @__PURE__ */ new Error("cannot append to compressed archives"));
|
|
3624
3377
|
if (c < 512) return h(null, l);
|
|
3625
3378
|
let E = new C(d);
|
|
3626
3379
|
if (!E.cksumValid) return h(null, l);
|
|
3627
3380
|
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
3628
3381
|
if (l + x + 512 > o || (l += x + 512, l >= o)) return h(null, l);
|
|
3629
|
-
s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0,
|
|
3382
|
+
s.mtimeCache && E.mtime && s.mtimeCache.set(String(E.path), E.mtime), c = 0, fs.read(n, d, 0, 512, l, S);
|
|
3630
3383
|
};
|
|
3631
|
-
|
|
3384
|
+
fs.read(n, d, 0, 512, l, S);
|
|
3632
3385
|
};
|
|
3633
3386
|
return new Promise((n, o) => {
|
|
3634
3387
|
e.on("error", o);
|
|
3635
3388
|
let a = "r+", h = (l, c) => {
|
|
3636
|
-
if (l && l.code === "ENOENT" && a === "r+") return a = "w+",
|
|
3389
|
+
if (l && l.code === "ENOENT" && a === "r+") return a = "w+", fs.open(s.file, a, h);
|
|
3637
3390
|
if (l || !c) return o(l);
|
|
3638
|
-
|
|
3639
|
-
if (d) return
|
|
3391
|
+
fs.fstat(c, (d, S) => {
|
|
3392
|
+
if (d) return fs.close(c, () => o(d));
|
|
3640
3393
|
i(c, S.size, (T, N) => {
|
|
3641
3394
|
if (T) return o(T);
|
|
3642
3395
|
let E = new tt(s.file, {
|
|
@@ -3647,7 +3400,7 @@ var mo = (s, t) => {
|
|
|
3647
3400
|
});
|
|
3648
3401
|
});
|
|
3649
3402
|
};
|
|
3650
|
-
|
|
3403
|
+
fs.open(s.file, a, h);
|
|
3651
3404
|
});
|
|
3652
3405
|
}, wo = (s, t) => {
|
|
3653
3406
|
t.forEach((e) => {
|
|
@@ -3878,7 +3631,7 @@ var SystemBackupService = class {
|
|
|
3878
3631
|
}
|
|
3879
3632
|
async statLocation(loc) {
|
|
3880
3633
|
const abs = path$1.isAbsolute(loc) ? loc : path$1.join(this.dataDir, loc);
|
|
3881
|
-
if (!fs$
|
|
3634
|
+
if (!fs$2.existsSync(abs)) return {
|
|
3882
3635
|
name: loc,
|
|
3883
3636
|
sizeBytes: 0,
|
|
3884
3637
|
fileCount: 0,
|
|
@@ -3925,11 +3678,11 @@ var SystemBackupService = class {
|
|
|
3925
3678
|
const present = [];
|
|
3926
3679
|
for (const loc of requested) {
|
|
3927
3680
|
const abs = path$1.isAbsolute(loc) ? loc : path$1.join(this.dataDir, loc);
|
|
3928
|
-
if (fs$
|
|
3681
|
+
if (fs$2.existsSync(abs)) present.push(loc);
|
|
3929
3682
|
else this.logger.debug("createArchive: skipping missing location", { meta: { location: loc } });
|
|
3930
3683
|
}
|
|
3931
3684
|
if (present.length === 0) throw new Error(`createArchive: no locations from {${requested.join(", ")}} exist under ${this.dataDir}`);
|
|
3932
|
-
fs$
|
|
3685
|
+
fs$2.mkdirSync(path$1.dirname(opts.archivePath), { recursive: true });
|
|
3933
3686
|
const walked = [];
|
|
3934
3687
|
for (const loc of present) {
|
|
3935
3688
|
throwIfCancelled(opts.signal);
|
|
@@ -4013,7 +3766,7 @@ var SystemBackupService = class {
|
|
|
4013
3766
|
*/
|
|
4014
3767
|
async createSnapshotsOnlyArchive(opts, selection, recipient) {
|
|
4015
3768
|
if (opts.owner === void 0) throw new BackupSnapshotRefusedError("a snapshots-only archive needs the database owner, and none was given");
|
|
4016
|
-
fs$
|
|
3769
|
+
fs$2.mkdirSync(path$1.dirname(opts.archivePath), { recursive: true });
|
|
4017
3770
|
const ownedById = await this.ownedDatabasesInScope(opts.owner, null);
|
|
4018
3771
|
const selected = /* @__PURE__ */ new Map();
|
|
4019
3772
|
for (const [rel, databaseId] of ownedById) if (selection.has(databaseId)) selected.set(rel, databaseId);
|
|
@@ -4067,7 +3820,7 @@ var SystemBackupService = class {
|
|
|
4067
3820
|
async writeArchive(opts) {
|
|
4068
3821
|
const { present, manifest } = opts;
|
|
4069
3822
|
const manifestStagePath = `${opts.archivePath}.${process.pid}.manifest.json`;
|
|
4070
|
-
fs$
|
|
3823
|
+
fs$2.writeFileSync(manifestStagePath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
4071
3824
|
this.logger.info("createArchive: tarring", { meta: {
|
|
4072
3825
|
archivePath: opts.archivePath,
|
|
4073
3826
|
locations: [...present],
|
|
@@ -4076,7 +3829,7 @@ var SystemBackupService = class {
|
|
|
4076
3829
|
} });
|
|
4077
3830
|
try {
|
|
4078
3831
|
const stagedInDataDir = path$1.join(this.dataDir, ARCHIVE_MANIFEST_NAME);
|
|
4079
|
-
fs$
|
|
3832
|
+
fs$2.copyFileSync(manifestStagePath, stagedInDataDir);
|
|
4080
3833
|
const stagingRel = path$1.relative(this.dataDir, path$1.dirname(opts.archivePath));
|
|
4081
3834
|
const excludePrefix = stagingRel && !stagingRel.startsWith("..") && !path$1.isAbsolute(stagingRel) ? stagingRel : null;
|
|
4082
3835
|
try {
|
|
@@ -4092,29 +3845,29 @@ var SystemBackupService = class {
|
|
|
4092
3845
|
return norm !== excludePrefix && !norm.startsWith(`${excludePrefix}/`);
|
|
4093
3846
|
}
|
|
4094
3847
|
}, [ARCHIVE_MANIFEST_NAME, ...opts.tarRoots ?? present]);
|
|
4095
|
-
const sink = fs$
|
|
3848
|
+
const sink = fs$2.createWriteStream(opts.archivePath, { mode: 384 });
|
|
4096
3849
|
try {
|
|
4097
3850
|
const streamOpts = opts.signal ? { signal: opts.signal } : {};
|
|
4098
3851
|
if (opts.encryptTo !== void 0) await pipeline(pack, createBackupEncryptStream(opts.encryptTo), byteCountingPassthrough(opts.onArchiveBytes), sink, streamOpts);
|
|
4099
3852
|
else await pipeline(pack, byteCountingPassthrough(opts.onArchiveBytes), sink, streamOpts);
|
|
4100
3853
|
} catch (err) {
|
|
4101
3854
|
try {
|
|
4102
|
-
fs$
|
|
3855
|
+
fs$2.rmSync(opts.archivePath, { force: true });
|
|
4103
3856
|
} catch {}
|
|
4104
3857
|
if (opts.signal?.aborted) throw new BackupCancelledError();
|
|
4105
3858
|
throw err;
|
|
4106
3859
|
}
|
|
4107
3860
|
} finally {
|
|
4108
3861
|
try {
|
|
4109
|
-
fs$
|
|
3862
|
+
fs$2.rmSync(stagedInDataDir, { force: true });
|
|
4110
3863
|
} catch {}
|
|
4111
3864
|
}
|
|
4112
3865
|
} finally {
|
|
4113
3866
|
try {
|
|
4114
|
-
fs$
|
|
3867
|
+
fs$2.rmSync(manifestStagePath, { force: true });
|
|
4115
3868
|
} catch {}
|
|
4116
3869
|
}
|
|
4117
|
-
const sizeBytes = fs$
|
|
3870
|
+
const sizeBytes = fs$2.statSync(opts.archivePath).size;
|
|
4118
3871
|
return {
|
|
4119
3872
|
archivePath: opts.archivePath,
|
|
4120
3873
|
includedLocations: [...present],
|
|
@@ -4127,7 +3880,7 @@ var SystemBackupService = class {
|
|
|
4127
3880
|
* one entry we care about, then aborts.
|
|
4128
3881
|
*/
|
|
4129
3882
|
async readArchiveManifest(archivePath) {
|
|
4130
|
-
if (!fs$
|
|
3883
|
+
if (!fs$2.existsSync(archivePath)) throw new Error(`readArchiveManifest: ${archivePath} does not exist`);
|
|
4131
3884
|
return new Promise((resolve, reject) => {
|
|
4132
3885
|
const chunks = [];
|
|
4133
3886
|
let found = false;
|
|
@@ -4159,7 +3912,7 @@ var SystemBackupService = class {
|
|
|
4159
3912
|
reject(err);
|
|
4160
3913
|
}
|
|
4161
3914
|
});
|
|
4162
|
-
const reader = fs$
|
|
3915
|
+
const reader = fs$2.createReadStream(archivePath);
|
|
4163
3916
|
reader.on("error", (err) => {
|
|
4164
3917
|
if (!resolved) {
|
|
4165
3918
|
resolved = true;
|
|
@@ -4177,7 +3930,7 @@ var SystemBackupService = class {
|
|
|
4177
3930
|
* restart.
|
|
4178
3931
|
*/
|
|
4179
3932
|
scheduleRestoreMarker(opts) {
|
|
4180
|
-
if (!fs$
|
|
3933
|
+
if (!fs$2.existsSync(opts.archivePath)) throw new Error(`scheduleRestoreMarker: ${opts.archivePath} missing`);
|
|
4181
3934
|
const markerPath = this.getRestoreMarkerPath();
|
|
4182
3935
|
const marker = {
|
|
4183
3936
|
archivePath: opts.archivePath,
|
|
@@ -4185,16 +3938,16 @@ var SystemBackupService = class {
|
|
|
4185
3938
|
source: opts.source,
|
|
4186
3939
|
...opts.locations ? { locations: [...opts.locations] } : {}
|
|
4187
3940
|
};
|
|
4188
|
-
fs$
|
|
4189
|
-
fs$
|
|
3941
|
+
fs$2.mkdirSync(path$1.dirname(markerPath), { recursive: true });
|
|
3942
|
+
fs$2.writeFileSync(markerPath, JSON.stringify(marker, null, 2), { mode: 384 });
|
|
4190
3943
|
return markerPath;
|
|
4191
3944
|
}
|
|
4192
3945
|
/** Read the pending-restore marker if one is present. */
|
|
4193
3946
|
readPendingMarker() {
|
|
4194
3947
|
const markerPath = this.getRestoreMarkerPath();
|
|
4195
|
-
if (!fs$
|
|
3948
|
+
if (!fs$2.existsSync(markerPath)) return null;
|
|
4196
3949
|
try {
|
|
4197
|
-
const raw = fs$
|
|
3950
|
+
const raw = fs$2.readFileSync(markerPath, "utf-8");
|
|
4198
3951
|
const parsed = JSON.parse(raw);
|
|
4199
3952
|
if (typeof parsed === "object" && parsed != null && typeof parsed.archivePath === "string") return parsed;
|
|
4200
3953
|
} catch (err) {
|
|
@@ -4205,7 +3958,7 @@ var SystemBackupService = class {
|
|
|
4205
3958
|
/** Drop the marker after a successful boot-time restore. */
|
|
4206
3959
|
clearPendingMarker() {
|
|
4207
3960
|
const markerPath = this.getRestoreMarkerPath();
|
|
4208
|
-
if (fs$
|
|
3961
|
+
if (fs$2.existsSync(markerPath)) fs$2.rmSync(markerPath, { force: true });
|
|
4209
3962
|
}
|
|
4210
3963
|
/**
|
|
4211
3964
|
* The databases the owner declares, archive-relative, that this walk found,
|
|
@@ -4457,4 +4210,4 @@ async function prepareRestoreArchive(input) {
|
|
|
4457
4210
|
}
|
|
4458
4211
|
}
|
|
4459
4212
|
//#endregion
|
|
4460
|
-
export {
|
|
4213
|
+
export { backupRecordStoresOf as _, BackupSnapshotRefusedError as a, BackupDecryptError as c, ENCRYPTED_BACKUP_SUFFIX as d, generateBackupKeyPair as f, backupOrchestratorRecordKinds as g, readBackupEncryptionHeader as h, BackupCancelledError as i, BackupKeyFormatError as l, parseBackupSecretKey as m, precheckRestoreKey as n, DEFAULT_BACKUP_DATABASES as o, parseBackupPublicKey as p, prepareRestoreArchive as r, SystemBackupService as s, BackupKeyRequiredError as t, BackupKeyMismatchError as u };
|