@ubercode/dcmtk 0.9.1 → 0.9.2

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.
@@ -1723,6 +1723,8 @@ declare class DicomReceiver extends EventEmitter<DicomReceiverEventMap> {
1723
1723
  private wireFileReceived;
1724
1724
  /** Moves a received file, opens it as DicomInstance, and emits FILE_RECEIVED. */
1725
1725
  private handleFileReceived;
1726
+ /** Inner handler: move file, parse DICOM, emit FILE_RECEIVED or error. */
1727
+ private moveAndEmitFile;
1726
1728
  /** Returns worker to idle pool on association complete, emits summary. */
1727
1729
  private wireAssociationComplete;
1728
1730
  /** Awaits pending file operations, emits ASSOCIATION_COMPLETE, resets worker state. */
@@ -1723,6 +1723,8 @@ declare class DicomReceiver extends EventEmitter<DicomReceiverEventMap> {
1723
1723
  private wireFileReceived;
1724
1724
  /** Moves a received file, opens it as DicomInstance, and emits FILE_RECEIVED. */
1725
1725
  private handleFileReceived;
1726
+ /** Inner handler: move file, parse DICOM, emit FILE_RECEIVED or error. */
1727
+ private moveAndEmitFile;
1726
1728
  /** Returns worker to idle pool on association complete, emits summary. */
1727
1729
  private wireAssociationComplete;
1728
1730
  /** Awaits pending file operations, emits ASSOCIATION_COMPLETE, resets worker state. */
package/dist/index.cjs CHANGED
@@ -36724,10 +36724,27 @@ var DicomReceiver = class _DicomReceiver extends events.EventEmitter {
36724
36724
  /** Moves a received file, opens it as DicomInstance, and emits FILE_RECEIVED. */
36725
36725
  async handleFileReceived(worker, data) {
36726
36726
  if (worker.associationDir === void 0 || worker.associationId === void 0) return;
36727
- const srcPath = data.filePath;
36728
- const destPath = path__namespace.join(worker.associationDir, path__namespace.basename(srcPath));
36729
36727
  const assocId = worker.associationId;
36730
36728
  const assocDir = worker.associationDir;
36729
+ try {
36730
+ await this.moveAndEmitFile(worker, data, assocId, assocDir);
36731
+ } catch (thrown) {
36732
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
36733
+ this.emit("error", {
36734
+ error,
36735
+ filePath: data.filePath,
36736
+ associationId: assocId,
36737
+ associationDir: assocDir,
36738
+ callingAE: data.callingAE,
36739
+ calledAE: data.calledAE,
36740
+ source: data.source
36741
+ });
36742
+ }
36743
+ }
36744
+ /** Inner handler: move file, parse DICOM, emit FILE_RECEIVED or error. */
36745
+ async moveAndEmitFile(worker, data, assocId, assocDir) {
36746
+ const srcPath = data.filePath;
36747
+ const destPath = path__namespace.join(assocDir, path__namespace.basename(srcPath));
36731
36748
  const moveResult = await moveFile(srcPath, destPath);
36732
36749
  const finalPath = moveResult.ok ? destPath : srcPath;
36733
36750
  const fileSize = await statFileSafe(finalPath);