rac-delta 1.0.19 → 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/core/services/reconstruction-service.d.ts +1 -2
- package/dist/core/services/reconstruction-service.d.ts.map +1 -1
- 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 +1 -1
- package/dist/infrastructure/services/memory-reconstruction-service.d.ts.map +1 -1
- package/dist/infrastructure/services/memory-reconstruction-service.js +43 -27
- package/package.json +1 -1
|
@@ -95,8 +95,7 @@ export interface ReconstructionService {
|
|
|
95
95
|
*
|
|
96
96
|
* @param entry The FileEntry containing the list of chunks of the file
|
|
97
97
|
* @param chunkSource the source implementations of the chunks
|
|
98
|
-
* @param maxConcurrency the max concurrent entries that will be processed
|
|
99
98
|
*/
|
|
100
|
-
reconstructToStream(entry: FileEntry, chunkSource: ChunkSource
|
|
99
|
+
reconstructToStream(entry: FileEntry, chunkSource: ChunkSource): Promise<Readable>;
|
|
101
100
|
}
|
|
102
101
|
//# sourceMappingURL=reconstruction-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconstruction-service.d.ts","sourceRoot":"","sources":["../../../src/core/services/reconstruction-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,yCAAyC,QAAoB,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;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OG;IACH,cAAc,CACZ,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB
|
|
1
|
+
{"version":3,"file":"reconstruction-service.d.ts","sourceRoot":"","sources":["../../../src/core/services/reconstruction-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,yCAAyC,QAAoB,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;OAcG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,CACX,mBAAmB,EAAE,MAAM,EAC3B,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EACjC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,KAC3B,IAAI,CAAC;CACX;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC;;OAEG;IACH,SAAS,CAAC,CACR,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAC1C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEhC;;;;;;;OAOG;IACH,YAAY,CAAC,CACX,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GACzF,cAAc,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,eAAe,CACb,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;OAOG;IACH,cAAc,CACZ,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACpF"}
|
|
@@ -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,EA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AM,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}`;
|
|
@@ -7,7 +7,7 @@ export declare class MemoryReconstructionService implements ReconstructionServic
|
|
|
7
7
|
constructor(hasher: HasherService);
|
|
8
8
|
reconstructAll(plan: DeltaPlan, outputDir: string, chunkSource: ChunkSource, options?: Nullish<ReconstructionOptions>): Promise<void>;
|
|
9
9
|
reconstructFile(entry: FileEntry, outputPath: string, chunkSource: ChunkSource, options?: ReconstructionOptions): Promise<void>;
|
|
10
|
-
reconstructToStream(entry: FileEntry, chunkSource: ChunkSource
|
|
10
|
+
reconstructToStream(entry: FileEntry, chunkSource: ChunkSource): Promise<Readable>;
|
|
11
11
|
private fileExists;
|
|
12
12
|
/** Performs partial reconstruction directly in the existing file */
|
|
13
13
|
private reconstructInPlace;
|
|
@@ -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,47 +115,49 @@ 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
|
}
|
|
113
125
|
// This will reconstruct to stream, not to disk
|
|
114
|
-
async reconstructToStream(entry, chunkSource
|
|
126
|
+
async reconstructToStream(entry, chunkSource) {
|
|
115
127
|
const chunks = entry.chunks ?? [];
|
|
116
|
-
const pass = new stream_1.PassThrough({ highWaterMark: 1024 * 1024 });
|
|
128
|
+
const pass = new stream_1.PassThrough({ highWaterMark: 2 * 1024 * 1024 });
|
|
117
129
|
const iterator = this.fetchChunksSmart(chunks, chunkSource, true);
|
|
118
130
|
pass.once('error', (err) => {
|
|
119
131
|
pass.destroy(err);
|
|
120
132
|
});
|
|
121
133
|
(async () => {
|
|
122
134
|
const active = new Set();
|
|
123
|
-
const pipeChunk = async (data) => {
|
|
124
|
-
if (Buffer.isBuffer(data)) {
|
|
125
|
-
if (!pass.write(data)) {
|
|
126
|
-
await new Promise((resolve) => pass.once('drain', resolve));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
await new Promise((resolve, reject) => {
|
|
131
|
-
data.pipe(pass, { end: false });
|
|
132
|
-
data.once('error', reject);
|
|
133
|
-
data.once('end', resolve);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
135
|
try {
|
|
138
136
|
for await (const { data } of iterator) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
if (Buffer.isBuffer(data)) {
|
|
138
|
+
if (!pass.write(data)) {
|
|
139
|
+
await new Promise((resolve) => pass.once('drain', resolve));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
await new Promise((resolve, reject) => {
|
|
144
|
+
data.pipe(pass, { end: false });
|
|
145
|
+
data.once('error', (err) => {
|
|
146
|
+
(pass.destroy(err), reject(err));
|
|
147
|
+
});
|
|
148
|
+
data.once('end', resolve);
|
|
149
|
+
data.once('close', () => {
|
|
150
|
+
if (!data.destroyed) {
|
|
151
|
+
console.warn('Chunk stream closed unexpectedly');
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
144
155
|
}
|
|
145
156
|
}
|
|
146
|
-
await Promise.all(active);
|
|
147
157
|
pass.end();
|
|
148
158
|
}
|
|
149
159
|
catch (err) {
|
|
160
|
+
console.error('Error during reconstruction: ', err);
|
|
150
161
|
pass.destroy(err instanceof Error ? err : new Error(String(err)));
|
|
151
162
|
}
|
|
152
163
|
})();
|
|
@@ -186,6 +197,7 @@ class MemoryReconstructionService {
|
|
|
186
197
|
}
|
|
187
198
|
/** Reconstructs file fully or partially via .tmp file and replaces it atomically */
|
|
188
199
|
async reconstructToTemp(entry, outputPath, tempPath, chunkSource, verifyAfterRebuild, fileExists, force, progressCb) {
|
|
200
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(tempPath), { recursive: true });
|
|
189
201
|
const writeStream = (0, fs_1.createWriteStream)(tempPath, { flags: 'w' });
|
|
190
202
|
let writeError = null;
|
|
191
203
|
const onWriteError = (err) => {
|
|
@@ -228,10 +240,6 @@ class MemoryReconstructionService {
|
|
|
228
240
|
writeStream.destroy();
|
|
229
241
|
throw err;
|
|
230
242
|
}
|
|
231
|
-
finally {
|
|
232
|
-
writeStream.removeListener('error', onWriteError);
|
|
233
|
-
writeStream.end();
|
|
234
|
-
}
|
|
235
243
|
}
|
|
236
244
|
writeStream.end();
|
|
237
245
|
await new Promise((resolve, reject) => {
|
|
@@ -247,8 +255,16 @@ class MemoryReconstructionService {
|
|
|
247
255
|
await (0, promises_1.rename)(tempPath, outputPath);
|
|
248
256
|
}
|
|
249
257
|
catch (err) {
|
|
258
|
+
try {
|
|
259
|
+
writeStream.destroy();
|
|
260
|
+
await (0, promises_1.rm)(tempPath, { force: true });
|
|
261
|
+
}
|
|
262
|
+
catch { }
|
|
250
263
|
throw err;
|
|
251
264
|
}
|
|
265
|
+
finally {
|
|
266
|
+
writeStream.removeListener('error', onWriteError);
|
|
267
|
+
}
|
|
252
268
|
}
|
|
253
269
|
/**
|
|
254
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": {
|