rac-delta 1.0.20 → 1.0.21
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/infrastructure/services/memory-delta-service.d.ts.map +1 -1
- package/dist/infrastructure/services/memory-delta-service.js +5 -1
- package/dist/infrastructure/services/memory-reconstruction-service.d.ts.map +1 -1
- package/dist/infrastructure/services/memory-reconstruction-service.js +22 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-delta-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/memory-delta-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AAErF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,kBAAmB,YAAW,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,wBAAwB,CAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,SAAI,EACf,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,GACjC,OAAO,CAAC,OAAO,CAAC;IA8Cb,yBAAyB,CAC7B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,CAAC;YAwBN,SAAS;IAuBxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"memory-delta-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/memory-delta-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AAErF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,kBAAmB,YAAW,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,wBAAwB,CAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,SAAI,EACf,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,GACjC,OAAO,CAAC,OAAO,CAAC;IA8Cb,yBAAyB,CAC7B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,CAAC;YAwBN,SAAS;IAuBxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS;IAsE3D,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS;IA0CpD,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;IAkBtF,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;CAG/F"}
|
|
@@ -131,13 +131,17 @@ class MemoryDeltaService {
|
|
|
131
131
|
const targetChunks = new Map(targetFile.chunks.map((c) => [`${c.hash}@${c.offset}`, c]));
|
|
132
132
|
const sourceChunkKeys = new Set(srcFile.chunks.map((c) => `${c.hash}@${c.offset}`));
|
|
133
133
|
// File exists -> compare chunks
|
|
134
|
+
let fileModified = false;
|
|
134
135
|
for (const chunk of srcFile.chunks) {
|
|
135
136
|
const key = `${chunk.hash}@${chunk.offset}`;
|
|
136
137
|
if (!targetChunks.has(key)) {
|
|
137
138
|
deltaPlan.missingChunks.push({ ...chunk, filePath: srcFile.path });
|
|
138
|
-
|
|
139
|
+
fileModified = true;
|
|
139
140
|
}
|
|
140
141
|
}
|
|
142
|
+
if (fileModified) {
|
|
143
|
+
deltaPlan.newAndModifiedFiles.push(srcFile);
|
|
144
|
+
}
|
|
141
145
|
// Check obsolete chunks in target that are not in source
|
|
142
146
|
for (const chunk of targetFile.chunks) {
|
|
143
147
|
const key = `${chunk.hash}@${chunk.offset}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-reconstruction-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/memory-reconstruction-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAyB,MAAM,QAAQ,CAAC;AAIzD,OAAO,EACL,WAAW,EAEX,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,2BAA4B,YAAW,qBAAqB;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,cAAc,CAClB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-reconstruction-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/memory-reconstruction-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAyB,MAAM,QAAQ,CAAC;AAIzD,OAAO,EACL,WAAW,EAEX,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,2BAA4B,YAAW,qBAAqB;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,cAAc,CAClB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC;IA8FV,eAAe,CACnB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,qBAIR,GACA,OAAO,CAAC,IAAI,CAAC;IAkDV,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;YA8C1E,UAAU;IASxB,oEAAoE;YACtD,kBAAkB;IAiChC,oFAAoF;YACtE,iBAAiB;IAyF/B;;;OAGG;YACW,qBAAqB;YA2BrB,YAAY;YAcZ,aAAa;YAyCZ,gBAAgB;CAmChC"}
|
|
@@ -17,6 +17,7 @@ class MemoryReconstructionService {
|
|
|
17
17
|
async reconstructAll(plan, outputDir, chunkSource, options) {
|
|
18
18
|
const dir = (0, path_1.isAbsolute)(outputDir) ? outputDir : (0, path_1.resolve)(process.cwd(), outputDir);
|
|
19
19
|
await (0, promises_1.mkdir)(dir, { recursive: true });
|
|
20
|
+
const activePaths = new Set();
|
|
20
21
|
const files = [...plan.newAndModifiedFiles];
|
|
21
22
|
const total = files.length;
|
|
22
23
|
let completed = 0;
|
|
@@ -35,6 +36,11 @@ class MemoryReconstructionService {
|
|
|
35
36
|
while (queue.length && !error) {
|
|
36
37
|
const { entry } = queue.shift();
|
|
37
38
|
const outputPath = (0, path_1.join)(dir, entry.path);
|
|
39
|
+
if (activePaths.has(outputPath)) {
|
|
40
|
+
queue.push({ entry, index: 0 });
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
activePaths.add(outputPath);
|
|
38
44
|
try {
|
|
39
45
|
await this.reconstructFile(entry, outputPath, chunkSource, {
|
|
40
46
|
...options,
|
|
@@ -66,6 +72,9 @@ class MemoryReconstructionService {
|
|
|
66
72
|
error = err instanceof Error ? err : new Error(String(err));
|
|
67
73
|
break;
|
|
68
74
|
}
|
|
75
|
+
finally {
|
|
76
|
+
activePaths.delete(outputPath);
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
79
|
};
|
|
71
80
|
const workers = Array.from({ length: Math.min(options?.fileConcurrency ?? 5, total) }, next);
|
|
@@ -106,7 +115,10 @@ class MemoryReconstructionService {
|
|
|
106
115
|
}
|
|
107
116
|
}
|
|
108
117
|
catch (err) {
|
|
109
|
-
|
|
118
|
+
try {
|
|
119
|
+
await (0, promises_1.rm)(tempPath, { force: true });
|
|
120
|
+
}
|
|
121
|
+
catch { }
|
|
110
122
|
throw err;
|
|
111
123
|
}
|
|
112
124
|
}
|
|
@@ -185,6 +197,7 @@ class MemoryReconstructionService {
|
|
|
185
197
|
}
|
|
186
198
|
/** Reconstructs file fully or partially via .tmp file and replaces it atomically */
|
|
187
199
|
async reconstructToTemp(entry, outputPath, tempPath, chunkSource, verifyAfterRebuild, fileExists, force, progressCb) {
|
|
200
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(tempPath), { recursive: true });
|
|
188
201
|
const writeStream = (0, fs_1.createWriteStream)(tempPath, { flags: 'w' });
|
|
189
202
|
let writeError = null;
|
|
190
203
|
const onWriteError = (err) => {
|
|
@@ -227,10 +240,6 @@ class MemoryReconstructionService {
|
|
|
227
240
|
writeStream.destroy();
|
|
228
241
|
throw err;
|
|
229
242
|
}
|
|
230
|
-
finally {
|
|
231
|
-
writeStream.removeListener('error', onWriteError);
|
|
232
|
-
writeStream.end();
|
|
233
|
-
}
|
|
234
243
|
}
|
|
235
244
|
writeStream.end();
|
|
236
245
|
await new Promise((resolve, reject) => {
|
|
@@ -246,8 +255,16 @@ class MemoryReconstructionService {
|
|
|
246
255
|
await (0, promises_1.rename)(tempPath, outputPath);
|
|
247
256
|
}
|
|
248
257
|
catch (err) {
|
|
258
|
+
try {
|
|
259
|
+
writeStream.destroy();
|
|
260
|
+
await (0, promises_1.rm)(tempPath, { force: true });
|
|
261
|
+
}
|
|
262
|
+
catch { }
|
|
249
263
|
throw err;
|
|
250
264
|
}
|
|
265
|
+
finally {
|
|
266
|
+
writeStream.removeListener('error', onWriteError);
|
|
267
|
+
}
|
|
251
268
|
}
|
|
252
269
|
/**
|
|
253
270
|
* Tries to read an existing chunk from a file descriptor if possible.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rac-delta",
|
|
3
3
|
"description": "Storage agnostic delta patching implementation of rac-delta protocol for NodeJs. With streaming support and file reconstruction.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.21",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"repository": {
|