@milaboratories/pl-drivers 1.5.71 → 1.5.73

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-drivers",
3
- "version": "1.5.71",
3
+ "version": "1.5.73",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -31,12 +31,12 @@
31
31
  "undici": "~7.10.0",
32
32
  "zod": "~3.23.8",
33
33
  "upath": "^2.0.1",
34
- "@milaboratories/helpers": "^1.6.14",
35
- "@milaboratories/ts-helpers": "^1.4.0",
36
34
  "@milaboratories/computable": "^2.5.0",
37
35
  "@milaboratories/pl-tree": "^1.6.10",
38
- "@milaboratories/pl-client": "^2.11.1",
39
- "@milaboratories/pl-model-common": "^1.15.5"
36
+ "@milaboratories/helpers": "^1.6.14",
37
+ "@milaboratories/pl-model-common": "^1.15.5",
38
+ "@milaboratories/ts-helpers": "^1.4.0",
39
+ "@milaboratories/pl-client": "^2.11.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "eslint": "^9.25.1",
@@ -47,8 +47,8 @@
47
47
  "vitest": "^2.1.9",
48
48
  "@vitest/coverage-v8": "^2.1.9",
49
49
  "@types/tar-fs": "^2.0.4",
50
- "@milaboratories/eslint-config": "^1.0.4",
51
- "@milaboratories/platforma-build-configs": "1.0.3"
50
+ "@milaboratories/platforma-build-configs": "1.0.3",
51
+ "@milaboratories/eslint-config": "^1.0.4"
52
52
  },
53
53
  "scripts": {
54
54
  "type-check": "tsc --noEmit --composite false",
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable n/no-unsupported-features/node-builtins */
2
2
  import type { GrpcClientProvider, GrpcClientProviderFactory } from '@milaboratories/pl-client';
3
- import { addRTypeToMetadata } from '@milaboratories/pl-client';
3
+ import { addRTypeToMetadata, stringifyWithResourceId } from '@milaboratories/pl-client';
4
4
  import type { ResourceInfo } from '@milaboratories/pl-tree';
5
5
  import type { MiLogger } from '@milaboratories/ts-helpers';
6
6
  import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
@@ -55,7 +55,7 @@ export class ClientDownload {
55
55
  const { downloadUrl, headers } = await this.grpcGetDownloadUrl(info, options, signal);
56
56
 
57
57
  const remoteHeaders = toHeadersMap(headers, fromBytes, toBytes);
58
- this.logger.info(`download blob from url ${downloadUrl}, headers: ${JSON.stringify(remoteHeaders)}`);
58
+ this.logger.info(`download blob ${stringifyWithResourceId(info)} from url ${downloadUrl}, headers: ${JSON.stringify(remoteHeaders)}`);
59
59
 
60
60
  return isLocal(downloadUrl)
61
61
  ? await this.readLocalFile(downloadUrl, fromBytes, toBytes)
@@ -19,6 +19,7 @@ import { Writable } from 'node:stream';
19
19
  import type { ClientDownload } from '../../clients/download';
20
20
  import { UnknownStorageError, WrongLocalFileUrl } from '../../clients/download';
21
21
  import { NetworkError400 } from '../../helpers/download';
22
+ import { stringifyWithResourceId } from '@milaboratories/pl-client';
22
23
 
23
24
  /** Downloads a blob and holds callers and watchers for the blob. */
24
25
  export class DownloadBlobTask {
@@ -60,12 +61,12 @@ export class DownloadBlobTask {
60
61
  this.setDone(size);
61
62
  this.change.markChanged();
62
63
  } catch (e: any) {
63
- this.logger.error(`task failed: ${e}, ${JSON.stringify(this.state)}`);
64
+ this.logger.error(`download blob ${stringifyWithResourceId(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`);
64
65
  if (nonRecoverableError(e)) {
65
66
  this.setError(e);
66
67
  this.change.markChanged();
67
68
  // Just in case we were half-way extracting an archive.
68
- await fsp.rm(this.path);
69
+ await fsp.rm(this.path, { force: true });
69
70
  }
70
71
 
71
72
  throw e;
@@ -73,15 +74,21 @@ export class DownloadBlobTask {
73
74
  }
74
75
 
75
76
  private async ensureDownloaded() {
77
+ this.signalCtl.signal.throwIfAborted();
78
+
76
79
  this.state = {};
77
80
  this.state.filePath = this.path;
78
81
  await ensureDirExists(path.dirname(this.state.filePath));
82
+ this.signalCtl.signal.throwIfAborted();
79
83
  this.state.dirExists = true;
80
84
 
81
- if (await fileExists(this.state.filePath)) {
85
+ const alreadyExists = await fileExists(this.state.filePath);
86
+ this.signalCtl.signal.throwIfAborted();
87
+ if (alreadyExists) {
82
88
  this.state.fileExists = true;
83
89
  this.logger.info(`a blob was already downloaded: ${this.state.filePath}`);
84
90
  const stat = await fsp.stat(this.state.filePath);
91
+ this.signalCtl.signal.throwIfAborted();
85
92
  this.state.fileSize = stat.size;
86
93
 
87
94
  return this.state.fileSize;
@@ -90,14 +97,14 @@ export class DownloadBlobTask {
90
97
  const { content, size } = await this.clientDownload.downloadBlob(
91
98
  this.rInfo,
92
99
  {},
93
- undefined,
100
+ this.signalCtl.signal,
94
101
  );
95
102
  this.state.fileSize = size;
96
103
  this.state.downloaded = true;
97
104
 
98
105
  await createPathAtomically(this.logger, this.state.filePath, async (fPath: string) => {
99
106
  const f = Writable.toWeb(fs.createWriteStream(fPath, { flags: 'wx' }));
100
- await content.pipeTo(f);
107
+ await content.pipeTo(f, { signal: this.signalCtl.signal });
101
108
  this.state.tempWritten = true;
102
109
  });
103
110