@storacha/clawracha 0.1.13 → 0.1.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/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +27 -21
- package/package.json +1 -1
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWxE,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,SAAS,EAAE,MAAM;IAK7B;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC/C;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;;OAGG;IACG,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAe1D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWxE,qBAAa,UAAU;IAC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@@ export class SyncEngine {
|
|
|
97
97
|
async sync() {
|
|
98
98
|
const { name } = this.requireRunning();
|
|
99
99
|
const beforeEntries = await this.getPailEntries();
|
|
100
|
-
|
|
101
|
-
if (pendingOps.length === 0) {
|
|
100
|
+
if (this.pendingOps.length === 0) {
|
|
102
101
|
// No pending ops — just pull remote
|
|
103
102
|
try {
|
|
104
103
|
const result = await Revision.resolve(this.blocks, name, {
|
|
@@ -113,28 +112,35 @@ export class SyncEngine {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
else {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
await this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
await this.storeBlocks(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
115
|
+
let pendingOps = [...this.pendingOps];
|
|
116
|
+
this.pendingOps = [];
|
|
117
|
+
try {
|
|
118
|
+
while (pendingOps.length > 0) {
|
|
119
|
+
if (!this.carFile) {
|
|
120
|
+
throw new Error("CAR file not initialized");
|
|
121
|
+
}
|
|
122
|
+
const { current, revisionBlocks, event, remainingOps } = await applyPendingOps(this.blocks, name, this.current, pendingOps);
|
|
123
|
+
this.current = current;
|
|
124
|
+
for (const block of revisionBlocks) {
|
|
125
|
+
await this.carFile.put(block);
|
|
126
|
+
}
|
|
127
|
+
await this.storeBlocks(revisionBlocks);
|
|
128
|
+
if (event) {
|
|
129
|
+
await this.carFile.put(event);
|
|
130
|
+
await this.storeBlocks([event]);
|
|
131
|
+
}
|
|
132
|
+
pendingOps = remainingOps;
|
|
133
|
+
await this.possiblyUploadCAR();
|
|
134
|
+
if (pendingOps.length > 0) {
|
|
135
|
+
this.carFile = await makeTempCar();
|
|
136
|
+
}
|
|
134
137
|
}
|
|
135
138
|
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
this.pendingOps.unshift(...pendingOps);
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
136
143
|
}
|
|
137
|
-
this.pendingOps = [];
|
|
138
144
|
// Apply remote changes
|
|
139
145
|
const afterEntries = await this.getPailEntries();
|
|
140
146
|
const remoteChanges = diffRemoteChanges(beforeEntries, afterEntries);
|