rac-delta 1.0.15 → 1.0.16

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.
@@ -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;IAmFV,eAAe,CACnB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,qBAIR,GACA,OAAO,CAAC,IAAI,CAAC;IAgDV,mBAAmB,CACvB,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,WAAW,EACxB,cAAc,GAAE,MAAU,GACzB,OAAO,CAAC,QAAQ,CAAC;YA6CN,UAAU;IASxB,oEAAoE;YACtD,kBAAkB;IAiChC,oFAAoF;YACtE,iBAAiB;IAmF/B;;;OAGG;YACW,qBAAqB;YA2BrB,YAAY;YAcZ,aAAa;YAyCZ,gBAAgB;CAmChC"}
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;IAmFV,eAAe,CACnB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,qBAIR,GACA,OAAO,CAAC,IAAI,CAAC;IAgDV,mBAAmB,CACvB,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,WAAW,EACxB,cAAc,SAAI,GACjB,OAAO,CAAC,QAAQ,CAAC;YA6CN,UAAU;IASxB,oEAAoE;YACtD,kBAAkB;IAiChC,oFAAoF;YACtE,iBAAiB;IAmF/B;;;OAGG;YACW,qBAAqB;YA2BrB,YAAY;YAcZ,aAAa;YAyCZ,gBAAgB;CAmChC"}
@@ -113,31 +113,33 @@ class MemoryReconstructionService {
113
113
  // This will reconstruct to stream, not to disk
114
114
  async reconstructToStream(entry, chunkSource, maxConcurrency = 5) {
115
115
  const chunks = entry.chunks ?? [];
116
- const iterator = this.fetchChunksSmart(chunks, chunkSource, true);
117
116
  const pass = new stream_1.PassThrough({ highWaterMark: 2 * 1024 * 1024 });
117
+ const iterator = this.fetchChunksSmart(chunks, chunkSource, true);
118
118
  (async () => {
119
+ const active = new Set();
120
+ const pipeChunk = async (data) => {
121
+ if (Buffer.isBuffer(data)) {
122
+ if (!pass.write(data)) {
123
+ await new Promise((resolve) => pass.once('drain', resolve));
124
+ }
125
+ }
126
+ else {
127
+ await new Promise((resolve, reject) => {
128
+ const onError = (err) => reject(err);
129
+ data.once('error', onError);
130
+ pass.once('error', onError);
131
+ data.once('end', resolve);
132
+ data.pipe(pass, { end: false });
133
+ });
134
+ }
135
+ };
119
136
  try {
120
- const active = new Set();
121
137
  for await (const { data } of iterator) {
122
- const task = (async () => {
123
- if (Buffer.isBuffer(data)) {
124
- if (!pass.write(data)) {
125
- await new Promise((resolve) => pass.once('drain', resolve));
126
- }
127
- }
128
- else {
129
- await new Promise((resolve, reject) => {
130
- data.on('error', reject);
131
- pass.on('error', reject);
132
- data.pipe(pass, { end: false });
133
- data.on('end', resolve);
134
- });
135
- }
136
- })();
138
+ const task = pipeChunk(data);
137
139
  active.add(task);
138
140
  task.finally(() => active.delete(task));
139
141
  if (active.size >= maxConcurrency) {
140
- const finished = await Promise.race(active);
142
+ await Promise.race(active);
141
143
  }
142
144
  }
143
145
  await Promise.all(active);
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.15",
4
+ "version": "1.0.16",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": {