rac-delta 1.0.4 → 1.0.7
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/delta-service.d.ts +2 -1
- package/dist/core/services/delta-service.d.ts.map +1 -1
- package/dist/core/services/hasher-service.d.ts +2 -1
- package/dist/core/services/hasher-service.d.ts.map +1 -1
- package/dist/infrastructure/adapters/ssh-storage-adapter.d.ts.map +1 -1
- package/dist/infrastructure/adapters/ssh-storage-adapter.js +1 -0
- package/dist/infrastructure/client.d.ts +3 -2
- package/dist/infrastructure/client.d.ts.map +1 -1
- package/dist/infrastructure/client.js +7 -3
- package/dist/infrastructure/services/hash-wasm-hasher-service.d.ts +1 -1
- package/dist/infrastructure/services/hash-wasm-hasher-service.d.ts.map +1 -1
- package/dist/infrastructure/services/hash-wasm-hasher-service.js +28 -6
- package/dist/infrastructure/services/memory-delta-service.d.ts +1 -1
- package/dist/infrastructure/services/memory-delta-service.d.ts.map +1 -1
- package/dist/infrastructure/services/memory-delta-service.js +2 -2
- package/package.json +1 -1
|
@@ -29,8 +29,9 @@ export interface DeltaService {
|
|
|
29
29
|
*
|
|
30
30
|
* @param stream An async stream providing file chunks.
|
|
31
31
|
* @param path Relative path of the source file
|
|
32
|
+
* @param chunkSize Size in bytes of chunk that will be processed
|
|
32
33
|
*/
|
|
33
|
-
createFileEntryFromStream(stream: AsyncChunkStream, path: string): Promise<FileEntry>;
|
|
34
|
+
createFileEntryFromStream(stream: AsyncChunkStream, path: string, chunkSize: number): Promise<FileEntry>;
|
|
34
35
|
/**
|
|
35
36
|
* Compare two rd-index.json and generate a DeltaPlan. (Neutral method, for more specific methods use compareForUpload or compareForDownload)
|
|
36
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delta-service.d.ts","sourceRoot":"","sources":["../../../src/core/services/delta-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE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AAO,CAAC,CAAC;IAEpB;;;;;;;;;;;;OAYG;IACH,yBAAyB,CACvB,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,CAAC,CAAC;IAEtB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5D;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAE3D;;;;;;OAMG;IACH,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACvF;;;;;OAKG;IACH,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAC1F"}
|
|
@@ -19,9 +19,10 @@ export interface HasherService {
|
|
|
19
19
|
* Will process a stream of Chunks and return an array of hashed Chunks
|
|
20
20
|
*
|
|
21
21
|
* @param stream
|
|
22
|
+
* @param chunkSize The size (in bytes) chunks will need to be processed and emited.
|
|
22
23
|
* @param onChunk callback that returns the processed bytes
|
|
23
24
|
*/
|
|
24
|
-
hashStream(stream: AsyncChunkStream, onChunk?: (chunk: Uint8Array, hash: string) => void): Promise<Chunk[]>;
|
|
25
|
+
hashStream(stream: AsyncChunkStream, chunkSize: number, onChunk?: (chunk: Uint8Array, hash: string) => void): Promise<Chunk[]>;
|
|
25
26
|
/**
|
|
26
27
|
* Returns a hash of a buffer
|
|
27
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasher-service.d.ts","sourceRoot":"","sources":["../../../src/core/services/hasher-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE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AAC;IAE9C;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjE,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-storage-adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/ssh-storage-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ssh-storage-adapter.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/ssh-storage-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C,qBAAa,iBAAkB,SAAQ,kBAAkB;IAM3C,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAa;IAE3B,OAAO,CAAC,UAAU,CAA6B;gBAElB,MAAM,EAAE,gBAAgB;YAIvC,OAAO;IA4CrB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,gBAAgB;IAKlB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAwBhD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBrD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3C,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAexC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAe/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAuBpD,cAAc,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAkC/C,OAAO,CAAC,UAAU;IAaZ,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAehB,mBAAmB;IAgBjC,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;CAKvB"}
|
|
@@ -37,6 +37,7 @@ exports.SSHStorageAdapter = void 0;
|
|
|
37
37
|
const stream_1 = require("stream");
|
|
38
38
|
const path_1 = require("path");
|
|
39
39
|
const adapters_1 = require("../../core/adapters");
|
|
40
|
+
// TODO: Replace anys with ssh2 types and see if peerDependencies break
|
|
40
41
|
class SSHStorageAdapter extends adapters_1.HashStorageAdapter {
|
|
41
42
|
config;
|
|
42
43
|
sftp = null;
|
|
@@ -38,8 +38,9 @@ export declare class RacDeltaClient<C extends StorageConfig = StorageConfig> {
|
|
|
38
38
|
readonly validation: ValidationService;
|
|
39
39
|
readonly reconstruction: ReconstructionService;
|
|
40
40
|
readonly pipelines: PipelineBundleFor<AdapterFromConfig<C>>;
|
|
41
|
-
constructor(
|
|
41
|
+
private constructor();
|
|
42
|
+
static create<C extends StorageConfig>(config: RacDeltaConfig & {
|
|
42
43
|
storage: C;
|
|
43
|
-
})
|
|
44
|
+
}): Promise<RacDeltaClient<C>>;
|
|
44
45
|
}
|
|
45
46
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/infrastructure/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAmB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAyB,MAAM,qCAAqC,CAAC;AAG/F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IACjE,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/infrastructure/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAmB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAyB,MAAM,qCAAqC,CAAC;AAG/F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IACjE,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5D,OAAO;WAgBM,MAAM,CAAC,CAAC,SAAS,aAAa,EACzC,MAAM,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,GACtC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAS9B"}
|
|
@@ -38,15 +38,19 @@ class RacDeltaClient {
|
|
|
38
38
|
validation;
|
|
39
39
|
reconstruction;
|
|
40
40
|
pipelines;
|
|
41
|
-
constructor(config) {
|
|
41
|
+
constructor(config, storage, services) {
|
|
42
42
|
this.config = config;
|
|
43
|
-
this.storage =
|
|
44
|
-
const services = service_factory_1.ServiceFactory.create();
|
|
43
|
+
this.storage = storage;
|
|
45
44
|
this.delta = services.delta;
|
|
46
45
|
this.hasher = services.hasher;
|
|
47
46
|
this.validation = services.validation;
|
|
48
47
|
this.reconstruction = services.reconstruction;
|
|
49
48
|
this.pipelines = pipeline_factory_1.PipelineFactory.create(this.storage, services, config);
|
|
50
49
|
}
|
|
50
|
+
static async create(config) {
|
|
51
|
+
const storage = (await storage_adpater_factory_1.StorageAdapterFactory.create(config.storage));
|
|
52
|
+
const services = service_factory_1.ServiceFactory.create();
|
|
53
|
+
return new RacDeltaClient(config, storage, services);
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
exports.RacDeltaClient = RacDeltaClient;
|
|
@@ -4,7 +4,7 @@ import { FileEntry, Chunk } from '../../core/models';
|
|
|
4
4
|
import { Nullish } from '../../core/types';
|
|
5
5
|
export declare class HashWasmHasherService implements HasherService {
|
|
6
6
|
hashFile(filePath: string, rootDir: string, chunkSize: number): Promise<FileEntry>;
|
|
7
|
-
hashStream(stream: AsyncChunkStream, onChunk?: Nullish<(chunk: Uint8Array, hash: string) => void>): Promise<Chunk[]>;
|
|
7
|
+
hashStream(stream: AsyncChunkStream, chunkSize: number, onChunk?: Nullish<(chunk: Uint8Array, hash: string) => void>): Promise<Chunk[]>;
|
|
8
8
|
verifyChunk(data: Uint8Array, expectedHash: string): Promise<boolean>;
|
|
9
9
|
hashBuffer(data: Uint8Array): Promise<string>;
|
|
10
10
|
verifyFile(path: string, expectedHash: string): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-wasm-hasher-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/hash-wasm-hasher-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,qBAAsB,YAAW,aAAa;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAiDlF,UAAU,CACd,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAC3D,OAAO,CAAC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"hash-wasm-hasher-service.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/hash-wasm-hasher-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,qBAAsB,YAAW,aAAa;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAiDlF,UAAU,CACd,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAC3D,OAAO,CAAC,KAAK,EAAE,CAAC;IAiEb,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAM7C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBhE,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC;CAYxD"}
|
|
@@ -46,23 +46,45 @@ class HashWasmHasherService {
|
|
|
46
46
|
throw err;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
async hashStream(stream, onChunk) {
|
|
49
|
+
async hashStream(stream, chunkSize, onChunk) {
|
|
50
|
+
if (!chunkSize || chunkSize <= 0) {
|
|
51
|
+
throw new Error('chunkSize must be a positive number.');
|
|
52
|
+
}
|
|
50
53
|
const chunks = [];
|
|
51
54
|
let offset = 0;
|
|
55
|
+
let buffer = Buffer.alloc(0);
|
|
52
56
|
try {
|
|
53
|
-
for await (const
|
|
57
|
+
for await (const data of stream) {
|
|
58
|
+
buffer = Buffer.concat([buffer, data]);
|
|
59
|
+
while (buffer.length >= chunkSize) {
|
|
60
|
+
const emitChunk = buffer.subarray(0, chunkSize);
|
|
61
|
+
const chunkHasher = await (0, hash_wasm_1.createBLAKE3)();
|
|
62
|
+
chunkHasher.update(emitChunk);
|
|
63
|
+
const chunkHash = chunkHasher.digest('hex');
|
|
64
|
+
if (onChunk) {
|
|
65
|
+
onChunk(emitChunk, chunkHash);
|
|
66
|
+
}
|
|
67
|
+
chunks.push({
|
|
68
|
+
hash: chunkHash,
|
|
69
|
+
offset,
|
|
70
|
+
size: emitChunk.length,
|
|
71
|
+
});
|
|
72
|
+
offset += emitChunk.length;
|
|
73
|
+
buffer = buffer.subarray(chunkSize);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (buffer.length > 0) {
|
|
54
77
|
const chunkHasher = await (0, hash_wasm_1.createBLAKE3)();
|
|
55
|
-
chunkHasher.update(
|
|
78
|
+
chunkHasher.update(buffer);
|
|
56
79
|
const chunkHash = chunkHasher.digest('hex');
|
|
57
80
|
if (onChunk) {
|
|
58
|
-
onChunk(
|
|
81
|
+
onChunk(buffer, chunkHash);
|
|
59
82
|
}
|
|
60
83
|
chunks.push({
|
|
61
84
|
hash: chunkHash,
|
|
62
85
|
offset,
|
|
63
|
-
size:
|
|
86
|
+
size: buffer.length,
|
|
64
87
|
});
|
|
65
|
-
offset += chunk.length;
|
|
66
88
|
}
|
|
67
89
|
if (stream.close) {
|
|
68
90
|
await stream.close();
|
|
@@ -5,7 +5,7 @@ export declare class MemoryDeltaService implements DeltaService {
|
|
|
5
5
|
private readonly hasher;
|
|
6
6
|
constructor(hasher: HasherService);
|
|
7
7
|
createIndexFromDirectory(rootPath: string, chunkSize: number, concurrency?: number, ignorePatterns?: Nullish<string[]>): Promise<RDIndex>;
|
|
8
|
-
createFileEntryFromStream(stream: AsyncChunkStream, path: string): Promise<FileEntry>;
|
|
8
|
+
createFileEntryFromStream(stream: AsyncChunkStream, path: string, chunkSize: number): Promise<FileEntry>;
|
|
9
9
|
private walkFiles;
|
|
10
10
|
private matchesAnyPattern;
|
|
11
11
|
private globToRegex;
|
|
@@ -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,EAAc,MAAM,mBAAmB,CAAC;AAE9E,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,
|
|
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,EAAc,MAAM,mBAAmB,CAAC;AAE9E,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;YAqBN,SAAS;IAuBxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS;IAiE3D,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"}
|
|
@@ -45,9 +45,9 @@ class MemoryDeltaService {
|
|
|
45
45
|
files: results,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
async createFileEntryFromStream(stream, path) {
|
|
48
|
+
async createFileEntryFromStream(stream, path, chunkSize) {
|
|
49
49
|
const fileHasher = await this.hasher.createStreamingHasher();
|
|
50
|
-
const chunks = await this.hasher.hashStream(stream, (chunk) => {
|
|
50
|
+
const chunks = await this.hasher.hashStream(stream, chunkSize, (chunk) => {
|
|
51
51
|
fileHasher.update(chunk);
|
|
52
52
|
});
|
|
53
53
|
const fileHash = fileHasher.digest('hex');
|
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.7",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"repository": {
|