filemail-sdk 9.3.4 → 9.4.0

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.
Files changed (231) hide show
  1. package/LICENSE +10 -10
  2. package/dist/src/autoDownloader/autoDownloader.js.map +1 -1
  3. package/dist/src/autoDownloader/autoDownloaderDestroyer.js.map +1 -1
  4. package/dist/src/autoDownloader/autoDownloaderError.js.map +1 -1
  5. package/dist/src/autoDownloader/autoDownloaderEvent.js.map +1 -1
  6. package/dist/src/autoDownloader/autoDownloaderOptions.js.map +1 -1
  7. package/dist/src/autoDownloader/autoDownloaderStateSerializer.js.map +1 -1
  8. package/dist/src/autoDownloader/eventArgs/autoDownloadEventArgs.js.map +1 -1
  9. package/dist/src/autoDownloader/eventArgs/autoDownloadFailedEventArgs.js.map +1 -1
  10. package/dist/src/autoDownloader/eventArgs/autoDownloadProgressedEventArgs.js.map +1 -1
  11. package/dist/src/autoDownloader/eventArgs/autoDownloadStartedEventArgs.js.map +1 -1
  12. package/dist/src/autoDownloader/eventArgs/autoDownloadStartingFailedEventArgs.js.map +1 -1
  13. package/dist/src/autoDownloader/eventArgs/autoDownloadUnhealthyEventArgs.js.map +1 -1
  14. package/dist/src/autoDownloader/eventArgs/checkingForNewTransfersStartedEventArgs.js.map +1 -1
  15. package/dist/src/autoDownloader/eventArgs/newTransfersCheckCompletedEventArgs.js.map +1 -1
  16. package/dist/src/autoDownloader/factory/nodeAutoDownloaderFactory.js.map +1 -1
  17. package/dist/src/autoDownloader/factory/nodeAutoDownloaderFactoryOptions.js.map +1 -1
  18. package/dist/src/autoDownloader/newInboxTransfersRetriever/newInboxTransfer.js.map +1 -1
  19. package/dist/src/autoDownloader/newInboxTransfersRetriever/newInboxTransfersRetriever.js.map +1 -1
  20. package/dist/src/autoDownloader/node/nodeAutoDownloaderStateSerializer.js.map +1 -1
  21. package/dist/src/autoDownloader/node/nodeTransferDownloaderFactory.js.map +1 -1
  22. package/dist/src/autoDownloader/state/autoDownloaderRecoverableState.js.map +1 -1
  23. package/dist/src/autoDownloader/state/autoDownloaderState.js.map +1 -1
  24. package/dist/src/autoDownloader/state/autoDownloaderStateRecoverableTransfer.js.map +1 -1
  25. package/dist/src/autoDownloader/state/autoDownloaderStateRunningTransfer.js.map +1 -1
  26. package/dist/src/autoDownloader/state/autoDownloaderStateSnapshot.js.map +1 -1
  27. package/dist/src/autoDownloader/transferDownloaderFactory.js.map +1 -1
  28. package/dist/src/autoDownloader/transferHandler/autoDownloaderNewTransferHandler.js.map +1 -1
  29. package/dist/src/autoDownloader/transferHandler/autoDownloaderRecoverableTransferHandler.js.map +1 -1
  30. package/dist/src/autoDownloader/transferHandler/autoDownloaderTransferHandlerBase.js.map +1 -1
  31. package/dist/src/client/downloader/downloaderCore.d.ts.map +1 -1
  32. package/dist/src/client/downloader/downloaderCore.js +6 -0
  33. package/dist/src/client/downloader/downloaderCore.js.map +1 -1
  34. package/dist/src/client/downloader/node/nodeTransferDownloader.js.map +1 -1
  35. package/dist/src/client/downloader/transferDownloader.js.map +1 -1
  36. package/dist/src/client/environmentVariables.js.map +1 -1
  37. package/dist/src/client/healthMonitor/events/eventArgs/healthMonitorHealthyEventArgs.js.map +1 -1
  38. package/dist/src/client/healthMonitor/events/eventArgs/healthMonitorUnhealthyEventArgs.js.map +1 -1
  39. package/dist/src/client/healthMonitor/events/transferHealthMonitorEvent.js.map +1 -1
  40. package/dist/src/client/healthMonitor/onlineChecker/nodeOnlineChecker.js.map +1 -1
  41. package/dist/src/client/healthMonitor/onlineChecker/onlineChecker.js.map +1 -1
  42. package/dist/src/client/healthMonitor/onlineChecker/webOnlineChecker.js.map +1 -1
  43. package/dist/src/client/healthMonitor/transferDownloaderHealthMonitor.js.map +1 -1
  44. package/dist/src/client/healthMonitor/transferHealthMonitorBase.js.map +1 -1
  45. package/dist/src/client/healthMonitor/transferUploaderHealthMonitor.js.map +1 -1
  46. package/dist/src/client/loggers/dummyLogger.js.map +1 -1
  47. package/dist/src/client/loggers/logger.js.map +1 -1
  48. package/dist/src/client/loggers/utils/logHealthyStatus.js.map +1 -1
  49. package/dist/src/client/node/nodeFileDetailsProvider.js.map +1 -1
  50. package/dist/src/client/uploader/node/nodeTransferUploader.js.map +1 -1
  51. package/dist/src/client/uploader/transferUploader.js.map +1 -1
  52. package/dist/src/client/uploader/transferUploaderBase.js.map +1 -1
  53. package/dist/src/client/uploader/transferUploaderConfig.js.map +1 -1
  54. package/dist/src/client/uploader/utils/uploaderUtils.js.map +1 -1
  55. package/dist/src/client/uploader/web/webTransferUploader.js.map +1 -1
  56. package/dist/src/downloader/api/fileServerDownloadClient.js.map +1 -1
  57. package/dist/src/downloader/api/node/nodeFileServerDownloadClient.js.map +1 -1
  58. package/dist/src/downloader/chunkDownloader.d.ts.map +1 -1
  59. package/dist/src/downloader/chunkDownloader.js +22 -3
  60. package/dist/src/downloader/chunkDownloader.js.map +1 -1
  61. package/dist/src/downloader/downloadFolderResolver.js.map +1 -1
  62. package/dist/src/downloader/downloadLogger.js.map +1 -1
  63. package/dist/src/downloader/downloadOptions.js.map +1 -1
  64. package/dist/src/downloader/downloadStatus/downloadFileChunkProgress.js.map +1 -1
  65. package/dist/src/downloader/downloadStatus/downloadFileProgress.js.map +1 -1
  66. package/dist/src/downloader/downloadStatus/downloadFilePromise.js.map +1 -1
  67. package/dist/src/downloader/downloadStatus/downloadState.d.ts +1 -0
  68. package/dist/src/downloader/downloadStatus/downloadState.d.ts.map +1 -1
  69. package/dist/src/downloader/downloadStatus/downloadState.js +4 -0
  70. package/dist/src/downloader/downloadStatus/downloadState.js.map +1 -1
  71. package/dist/src/downloader/downloadTracker.d.ts.map +1 -1
  72. package/dist/src/downloader/downloadTracker.js +31 -0
  73. package/dist/src/downloader/downloadTracker.js.map +1 -1
  74. package/dist/src/downloader/dtos/downloadCommand.js.map +1 -1
  75. package/dist/src/downloader/dtos/downloadError.js.map +1 -1
  76. package/dist/src/downloader/dtos/downloadErrorCode.js.map +1 -1
  77. package/dist/src/downloader/dtos/downloadEvent.js.map +1 -1
  78. package/dist/src/downloader/dtos/downloadFileChunkInfo.js.map +1 -1
  79. package/dist/src/downloader/dtos/downloadFileInfo.js.map +1 -1
  80. package/dist/src/downloader/dtos/downloadFilesCommand.js.map +1 -1
  81. package/dist/src/downloader/dtos/downloadInfo.js.map +1 -1
  82. package/dist/src/downloader/dtos/downloadRegistrationMode.js.map +1 -1
  83. package/dist/src/downloader/dtos/downloadTrackerFileInfo.js.map +1 -1
  84. package/dist/src/downloader/dtos/downloadTrackerFileProgressInfo.d.ts +5 -0
  85. package/dist/src/downloader/dtos/downloadTrackerFileProgressInfo.d.ts.map +1 -1
  86. package/dist/src/downloader/dtos/downloadTrackerFileProgressInfo.js.map +1 -1
  87. package/dist/src/downloader/dtos/downloadTrackerProgressInfo.js.map +1 -1
  88. package/dist/src/downloader/dtos/downloadTrackingMetadata.js.map +1 -1
  89. package/dist/src/downloader/dtos/downloaderRestoredState.js.map +1 -1
  90. package/dist/src/downloader/eventArgs/chunkDownloadEventArgs.js.map +1 -1
  91. package/dist/src/downloader/eventArgs/chunkDownloadFailedEventArgs.js.map +1 -1
  92. package/dist/src/downloader/eventArgs/downloadCompletedEventArgs.js.map +1 -1
  93. package/dist/src/downloader/eventArgs/downloadEventArgs.js.map +1 -1
  94. package/dist/src/downloader/eventArgs/downloadMetadataDeterminedEventArgs.js.map +1 -1
  95. package/dist/src/downloader/eventArgs/downloadPauseEventArgs.js.map +1 -1
  96. package/dist/src/downloader/eventArgs/downloadTrackingFailedEventArgs.js.map +1 -1
  97. package/dist/src/downloader/eventArgs/fileDownloadEventArgs.js.map +1 -1
  98. package/dist/src/downloader/eventArgs/fileDownloadFailedEventArgs.js.map +1 -1
  99. package/dist/src/downloader/filesDownloader.d.ts.map +1 -1
  100. package/dist/src/downloader/filesDownloader.js +97 -6
  101. package/dist/src/downloader/filesDownloader.js.map +1 -1
  102. package/dist/src/downloader/filesPreparer.js.map +1 -1
  103. package/dist/src/index.js.map +1 -1
  104. package/dist/src/index.node.js.map +1 -1
  105. package/dist/src/index.web.js.map +1 -1
  106. package/dist/src/uploader/api/dtos/handshakeRequest.js.map +1 -1
  107. package/dist/src/uploader/api/dtos/handshakeResponse.js.map +1 -1
  108. package/dist/src/uploader/api/dtos/pingResponse.js.map +1 -1
  109. package/dist/src/uploader/api/dtos/sendChunkRequest.js.map +1 -1
  110. package/dist/src/uploader/api/fileServerUdpClient.js.map +1 -1
  111. package/dist/src/uploader/api/fileServerUploadClient.js.map +1 -1
  112. package/dist/src/uploader/api/node/nodeFileServerUdpClient.js +8 -8
  113. package/dist/src/uploader/api/node/nodeFileServerUdpClient.js.map +1 -1
  114. package/dist/src/uploader/api/node/nodeFileServerUploadClient.js.map +1 -1
  115. package/dist/src/uploader/api/web/utils/axiosIdleTimeoutManager.js.map +1 -1
  116. package/dist/src/uploader/api/web/webFileServerUploadClient.js.map +1 -1
  117. package/dist/src/uploader/chunkStreamProviderFactory/nodeFileDetailsUploaderChunkStreamProviderFactory.js.map +1 -1
  118. package/dist/src/uploader/chunkStreamProviderFactory/uploaderChunkStreamProviderFactory.js.map +1 -1
  119. package/dist/src/uploader/chunkStreamProviderFactory/webFileDetailsUploaderChunkStreamProviderFactory.js.map +1 -1
  120. package/dist/src/uploader/chunksIterator/chunksIterator.js.map +1 -1
  121. package/dist/src/uploader/eventArgs/fileChunkUploadCompletedEventArgs.js.map +1 -1
  122. package/dist/src/uploader/eventArgs/fileChunkUploadCompletedPartiallyEventArgs.js.map +1 -1
  123. package/dist/src/uploader/eventArgs/fileChunkUploadEventArgs.js.map +1 -1
  124. package/dist/src/uploader/eventArgs/fileChunkUploadFailedEventArgs.js.map +1 -1
  125. package/dist/src/uploader/eventArgs/fileChunkUploadProgressedEventArgs.js.map +1 -1
  126. package/dist/src/uploader/eventArgs/fileUploadEventArgs.js.map +1 -1
  127. package/dist/src/uploader/eventArgs/fileUploadFailedEventArgs.js.map +1 -1
  128. package/dist/src/uploader/eventArgs/transferMetadataDeterminedEventArgs.js.map +1 -1
  129. package/dist/src/uploader/eventArgs/transferUploadCompletedEventArgs.js.map +1 -1
  130. package/dist/src/uploader/eventArgs/transferUploadModeChosenEventArgs.js.map +1 -1
  131. package/dist/src/uploader/eventArgs/transferUploadProgressedEventArgs.js.map +1 -1
  132. package/dist/src/uploader/export/transferUploadExportData.js.map +1 -1
  133. package/dist/src/uploader/export/transferUploadExportState.js.map +1 -1
  134. package/dist/src/uploader/export/transferUploadMetadata.js.map +1 -1
  135. package/dist/src/uploader/optimizer/optimizationValues.js.map +1 -1
  136. package/dist/src/uploader/optimizer/strategies/udpConcurrencyBasedOptimizationStrategy.js.map +1 -1
  137. package/dist/src/uploader/optimizer/strategies/udpSleepBasedOptimizationStrategy.js.map +1 -1
  138. package/dist/src/uploader/optimizer/transferUploadOptimizationStrategy.js.map +1 -1
  139. package/dist/src/uploader/optimizer/transferUploadOptimizer.js.map +1 -1
  140. package/dist/src/uploader/optimizer/uploadOptimizer.js.map +1 -1
  141. package/dist/src/uploader/options/transferUploadAppendInfo.js.map +1 -1
  142. package/dist/src/uploader/options/transferUploadConfig.js.map +1 -1
  143. package/dist/src/uploader/options/transferUploadInfo.js.map +1 -1
  144. package/dist/src/uploader/options/transferUploadInfoBase.js.map +1 -1
  145. package/dist/src/uploader/pauseController.js.map +1 -1
  146. package/dist/src/uploader/state/continuousChunksCalculator.js.map +1 -1
  147. package/dist/src/uploader/state/readonlyTransferUploadStateFile.js.map +1 -1
  148. package/dist/src/uploader/state/readonlyTransferUploadStateFiles.js.map +1 -1
  149. package/dist/src/uploader/state/transferUploadProgressCalculator.js.map +1 -1
  150. package/dist/src/uploader/state/transferUploadState.js.map +1 -1
  151. package/dist/src/uploader/state/transferUploadStateFile.js.map +1 -1
  152. package/dist/src/uploader/state/transferUploadStateFiles.js.map +1 -1
  153. package/dist/src/uploader/transferUpload.js.map +1 -1
  154. package/dist/src/uploader/transferUploadError.js.map +1 -1
  155. package/dist/src/uploader/transferUploadEvent.js.map +1 -1
  156. package/dist/src/utils/api/apiClient.js.map +1 -1
  157. package/dist/src/utils/api/apiClientBase.js.map +1 -1
  158. package/dist/src/utils/api/apiError.js.map +1 -1
  159. package/dist/src/utils/api/apiFilemail449Error.js.map +1 -1
  160. package/dist/src/utils/api/apiFilemailError.js.map +1 -1
  161. package/dist/src/utils/api/dtos/baseResponse.js.map +1 -1
  162. package/dist/src/utils/api/dtos/cancelTransferRequest.js.map +1 -1
  163. package/dist/src/utils/api/dtos/finalizeTransferRequest.js.map +1 -1
  164. package/dist/src/utils/api/dtos/finalizeTransferResponse.js.map +1 -1
  165. package/dist/src/utils/api/dtos/getCompanyResponse.js.map +1 -1
  166. package/dist/src/utils/api/dtos/getCompressedFileMetadataResponse.js.map +1 -1
  167. package/dist/src/utils/api/dtos/getInboxTransfersRequest.js.map +1 -1
  168. package/dist/src/utils/api/dtos/getInboxTransfersResponse.js.map +1 -1
  169. package/dist/src/utils/api/dtos/getRangehashResponse.js.map +1 -1
  170. package/dist/src/utils/api/dtos/getTransferRequest.js.map +1 -1
  171. package/dist/src/utils/api/dtos/getTransferResponse.js.map +1 -1
  172. package/dist/src/utils/api/dtos/initializeTransferRequest.js.map +1 -1
  173. package/dist/src/utils/api/dtos/initializeTransferResponse.js.map +1 -1
  174. package/dist/src/utils/api/dtos/loginRequest.js.map +1 -1
  175. package/dist/src/utils/api/dtos/loginResponse.js.map +1 -1
  176. package/dist/src/utils/api/dtos/registerFileDownloadRequest.js.map +1 -1
  177. package/dist/src/utils/api/dtos/registerTransferDownloadRequest.js.map +1 -1
  178. package/dist/src/utils/api/dtos/resetTransferRequest.js.map +1 -1
  179. package/dist/src/utils/api/dtos/sendFileChunkRequest.js.map +1 -1
  180. package/dist/src/utils/api/dtos/transferCustomFieldDto.js.map +1 -1
  181. package/dist/src/utils/api/dtos/transferFileDto.js.map +1 -1
  182. package/dist/src/utils/api/fileServerClientFactory.js.map +1 -1
  183. package/dist/src/utils/api/node/gotWorkarounds.js.map +1 -1
  184. package/dist/src/utils/api/node/nodeApiClient.js.map +1 -1
  185. package/dist/src/utils/api/node/nodeClientBase.js.map +1 -1
  186. package/dist/src/utils/api/node/nodeFileServerClientFactory.js.map +1 -1
  187. package/dist/src/utils/api/node/nodeFileserverClientBase.js.map +1 -1
  188. package/dist/src/utils/api/urlUtil.js.map +1 -1
  189. package/dist/src/utils/api/web/webApiClient.js.map +1 -1
  190. package/dist/src/utils/api/web/webClientBase.js.map +1 -1
  191. package/dist/src/utils/api/web/webFileServerClientFactory.js.map +1 -1
  192. package/dist/src/utils/api/web/webFileserverClientBase.js.map +1 -1
  193. package/dist/src/utils/concurrencyController/concurrencyController.js.map +1 -1
  194. package/dist/src/utils/concurrencyController/concurrencyReleaser.js.map +1 -1
  195. package/dist/src/utils/concurrencyController/transferConcurrencyController.js.map +1 -1
  196. package/dist/src/utils/crypto/cryptographyProvider.js.map +1 -1
  197. package/dist/src/utils/crypto/node/nodeCryptographyProvider.js.map +1 -1
  198. package/dist/src/utils/crypto/web/webCryptographyProvider.js.map +1 -1
  199. package/dist/src/utils/dateAndTime/simpleDateFormatter.js.map +1 -1
  200. package/dist/src/utils/events/chunkProgressEvent.js.map +1 -1
  201. package/dist/src/utils/events/eventsEngine.js.map +1 -1
  202. package/dist/src/utils/events/node/nodeEventsEngine.js.map +1 -1
  203. package/dist/src/utils/events/web/webEventsEngine.js.map +1 -1
  204. package/dist/src/utils/fileSystem/chunkStreamProvider.js.map +1 -1
  205. package/dist/src/utils/fileSystem/chunkStreamProviderFactory.js.map +1 -1
  206. package/dist/src/utils/fileSystem/fileDetails.js.map +1 -1
  207. package/dist/src/utils/fileSystem/fileSystemService.d.ts +2 -2
  208. package/dist/src/utils/fileSystem/fileSystemService.d.ts.map +1 -1
  209. package/dist/src/utils/fileSystem/fileSystemService.js.map +1 -1
  210. package/dist/src/utils/fileSystem/fsError.js.map +1 -1
  211. package/dist/src/utils/fileSystem/node/nodeChunkStreamProvider.js.map +1 -1
  212. package/dist/src/utils/fileSystem/node/nodeChunkStreamProviderFactory.js.map +1 -1
  213. package/dist/src/utils/fileSystem/node/nodeFileDetails.js.map +1 -1
  214. package/dist/src/utils/fileSystem/node/nodeFileSystemService.d.ts +2 -1
  215. package/dist/src/utils/fileSystem/node/nodeFileSystemService.d.ts.map +1 -1
  216. package/dist/src/utils/fileSystem/node/nodeFileSystemService.js +15 -4
  217. package/dist/src/utils/fileSystem/node/nodeFileSystemService.js.map +1 -1
  218. package/dist/src/utils/fileSystem/parsedPath.js.map +1 -1
  219. package/dist/src/utils/fileSystem/web/chunkStreamProvider/webChunkStreamEncrypter.js.map +1 -1
  220. package/dist/src/utils/fileSystem/web/chunkStreamProvider/webChunkStreamProvider.js.map +1 -1
  221. package/dist/src/utils/fileSystem/web/webChunkStreamProviderFactory.js.map +1 -1
  222. package/dist/src/utils/fileSystem/web/webFileDetails.js.map +1 -1
  223. package/dist/src/utils/jsonParsing.js.map +1 -1
  224. package/dist/src/utils/logging/logEventPropertyNames.js.map +1 -1
  225. package/dist/src/utils/mergeAbortAndPauseSignals.js.map +1 -1
  226. package/dist/src/utils/networking/throttlingOptions.js.map +1 -1
  227. package/dist/src/utils/promiseAll.js.map +1 -1
  228. package/dist/src/utils/types/transferStatus.js.map +1 -1
  229. package/dist/src/utils/uint8ArrayUtils.js.map +1 -1
  230. package/package.json +79 -79
  231. package/readme.md +18 -18
@@ -1 +1 @@
1
- {"version":3,"file":"downloadFolderResolver.js","sourceRoot":"","sources":["../../../src/downloader/downloadFolderResolver.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,6CAA6C,CAAC;AAG9E,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACvC,MAAM,CAAC,iBAAiB,CAAC,IAAY;QACjC,OAAO,IAAI;aACN,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;I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N,sBAAsB,CAAC,6BAA6B,CAAC,EAAE,CAAC,KAAK,CAAC,EAC9D,EAAE,CAAC,KAAK,CACX,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;QACD,kFAAkF;QAClF;;;;;UAKE;QAEF,oIAAoI;QACpI,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,0BAA0B,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YACjE,4CAA4C;YAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC9C,OAAO,YAAY,KAAK,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC5B,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAEzD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB;QAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE;YACnC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;QAEpC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC","sourcesContent":["import SimpleDateFormatter from \"../utils/dateAndTime/simpleDateFormatter.js\";\r\nimport type GetTransferResponse from \"../utils/api/dtos/getTransferResponse.js\";\r\n\r\nconst DefaultMaxPlaceholderLength = 60;\r\n\r\nexport default class DownloadFolderResolver {\r\n static #pathFriendlyDate(date: string): string {\r\n return date\r\n .replace(/:+/g, `-`)\r\n .replace(/-+/g, `-`);\r\n }\r\n\r\n static #sanitizePathElement(value: string | null | undefined): string {\r\n if (!value)\r\n return ``;\r\n\r\n return value\r\n .replaceAll(`..\\\\`, ``)\r\n .replaceAll(`../`, ``)\r\n .replaceAll(`..`, ``)\r\n .replaceAll(`:`, ``)\r\n .replaceAll(`<`, ``)\r\n .replaceAll(`>`, ``)\r\n .replaceAll(`\\\\`, ``)\r\n .replaceAll(`/`, ``)\r\n .replace(/(\\n|\\r\\n){1,}/g, ` `);\r\n }\r\n\r\n static #getDomain(fromEmail: string | null | undefined) {\r\n if (fromEmail) {\r\n const idx = fromEmail.indexOf(`@`);\r\n if (idx > -1)\r\n return fromEmail.substring(idx + 1);\r\n }\r\n return `[missing_domain]`;\r\n }\r\n\r\n static #escapeRegExp(str: string): string {\r\n return str.replace(/[.*+?^${}()|[\\]\\\\/-]/g, `\\\\$&`);\r\n }\r\n\r\n static #placeholderRegexForSubstring = (token: string) => {\r\n // eslint-disable-next-line no-param-reassign\r\n token = this.#escapeRegExp(token);\r\n return new RegExp(`<${token}(:(.*?))?>`, `g`);\r\n };\r\n\r\n static #replacePlaceholderWithMaxLength(input: string, rx: RegExp, replaceValue: string): string {\r\n return input.replace(rx, (_0: any, _1: any, maxLength: string | undefined): string => {\r\n let substringLength = DefaultMaxPlaceholderLength;\r\n if (!!maxLength && maxLength.length > 0) {\r\n try {\r\n substringLength = parseInt(maxLength, 10);\r\n if (Number.isNaN(substringLength))\r\n substringLength = DefaultMaxPlaceholderLength;\r\n }\r\n catch {\r\n substringLength = DefaultMaxPlaceholderLength;\r\n }\r\n }\r\n\r\n const sanitized = DownloadFolderResolver.#sanitizePathElement(replaceValue);\r\n\r\n if (substringLength < 0)\r\n return sanitized.substring(sanitized.length + substringLength);\r\n\r\n return sanitized.substring(0, substringLength);\r\n });\r\n }\r\n\r\n static prepareDownloadFolder(template: string, transfer: GetTransferResponse) {\r\n let result = template;\r\n if (transfer.from) {\r\n const domain = DownloadFolderResolver.#getDomain(transfer.from);\r\n result = result\r\n .replaceAll(`<domain>`, DownloadFolderResolver.#sanitizePathElement(domain))\r\n .replaceAll(`<emailfrom>`, DownloadFolderResolver.#sanitizePathElement(transfer.from));\r\n }\r\n result = result.replaceAll(`<id>`, transfer.id);\r\n\r\n // datesent\r\n result = result.replace(/<datesent(:(.*?))?>/g, (_0: any, _1: any, dateFormatString: string | undefined): string => {\r\n const dateFormatted = SimpleDateFormatter.formatDateAndTimeLocal(transfer.sentdate, dateFormatString);\r\n return DownloadFolderResolver.#sanitizePathElement(DownloadFolderResolver.#pathFriendlyDate(dateFormatted));\r\n });\r\n\r\n if (transfer.message) {\r\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\r\n result,\r\n DownloadFolderResolver.#placeholderRegexForSubstring(`description`),\r\n transfer.message,\r\n );\r\n }\r\n\r\n if (transfer.subject) {\r\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\r\n result,\r\n DownloadFolderResolver.#placeholderRegexForSubstring(`subject`),\r\n transfer.subject,\r\n );\r\n }\r\n\r\n if (transfer.to && transfer.to.length) {\r\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\r\n result,\r\n DownloadFolderResolver.#placeholderRegexForSubstring(`emailto`),\r\n transfer.to.join(`,`),\r\n );\r\n }\r\n\r\n if (transfer.customfields && transfer.customfields.length) {\r\n for (const cf of transfer.customfields) {\r\n if (cf.label && cf.value) {\r\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\r\n result,\r\n DownloadFolderResolver.#placeholderRegexForSubstring(cf.label),\r\n cf.value,\r\n );\r\n }\r\n }\r\n }\r\n // remaining custom fields which have not bee replaced from transfer - remove them\r\n /*\r\n if (company && company.customfields && company.customfields.length) {\r\n for (const cf of company.customfields)\r\n result = result.replace(new RegExp(`<${cf.label}>`, `ig`), ``);\r\n }\r\n */\r\n\r\n // replace remaining < and > (they are used as placeholder boundaries) and other chars which are not allowed in Windows folder paths\r\n result = result.replace(/<([^:>]+)(?::([^>]*))?>/g, (_match, name) => {\r\n // Remove backslashes from the captured name\r\n const clean = String(name).replace(/\\\\/g, ``);\r\n return `[missing_${clean}]`;\r\n });\r\n\r\n if (process.platform === `win32`)\r\n result = DownloadFolderResolver.#trimFolders(result);\r\n\r\n return result;\r\n }\r\n\r\n static #trimFolders(template: string) {\r\n const folders = template.replaceAll(`/`, `\\\\`).split(`\\\\`);\r\n\r\n for (let i = 0; i < folders.length; i++)\r\n folders[i] = folders[i]!.trim();\r\n\r\n return folders.join(`\\\\`);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"downloadFolderResolver.js","sourceRoot":"","sources":["../../../src/downloader/downloadFolderResolver.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,6CAA6C,CAAC;AAG9E,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACvC,MAAM,CAAC,iBAAiB,CAAC,IAAY;QACjC,OAAO,IAAI;aACN,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,KAAgC;QACxD,IAAI,CAAC,KAAK;YACN,OAAO,EAAE,CAAC;QAEd,OAAO,KAAK;aACP,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;aACtB,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;aACrB,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;aACpB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;aACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;aACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;aACnB,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;aACpB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;aACnB,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,SAAoC;QAClD,IAAI,SAAS,EA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AAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB;QAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE;YACnC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;QAEpC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC","sourcesContent":["import SimpleDateFormatter from \"../utils/dateAndTime/simpleDateFormatter.js\";\nimport type GetTransferResponse from \"../utils/api/dtos/getTransferResponse.js\";\n\nconst DefaultMaxPlaceholderLength = 60;\n\nexport default class DownloadFolderResolver {\n static #pathFriendlyDate(date: string): string {\n return date\n .replace(/:+/g, `-`)\n .replace(/-+/g, `-`);\n }\n\n static #sanitizePathElement(value: string | null | undefined): string {\n if (!value)\n return ``;\n\n return value\n .replaceAll(`..\\\\`, ``)\n .replaceAll(`../`, ``)\n .replaceAll(`..`, ``)\n .replaceAll(`:`, ``)\n .replaceAll(`<`, ``)\n .replaceAll(`>`, ``)\n .replaceAll(`\\\\`, ``)\n .replaceAll(`/`, ``)\n .replace(/(\\n|\\r\\n){1,}/g, ` `);\n }\n\n static #getDomain(fromEmail: string | null | undefined) {\n if (fromEmail) {\n const idx = fromEmail.indexOf(`@`);\n if (idx > -1)\n return fromEmail.substring(idx + 1);\n }\n return `[missing_domain]`;\n }\n\n static #escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\/-]/g, `\\\\$&`);\n }\n\n static #placeholderRegexForSubstring = (token: string) => {\n // eslint-disable-next-line no-param-reassign\n token = this.#escapeRegExp(token);\n return new RegExp(`<${token}(:(.*?))?>`, `g`);\n };\n\n static #replacePlaceholderWithMaxLength(input: string, rx: RegExp, replaceValue: string): string {\n return input.replace(rx, (_0: any, _1: any, maxLength: string | undefined): string => {\n let substringLength = DefaultMaxPlaceholderLength;\n if (!!maxLength && maxLength.length > 0) {\n try {\n substringLength = parseInt(maxLength, 10);\n if (Number.isNaN(substringLength))\n substringLength = DefaultMaxPlaceholderLength;\n }\n catch {\n substringLength = DefaultMaxPlaceholderLength;\n }\n }\n\n const sanitized = DownloadFolderResolver.#sanitizePathElement(replaceValue);\n\n if (substringLength < 0)\n return sanitized.substring(sanitized.length + substringLength);\n\n return sanitized.substring(0, substringLength);\n });\n }\n\n static prepareDownloadFolder(template: string, transfer: GetTransferResponse) {\n let result = template;\n if (transfer.from) {\n const domain = DownloadFolderResolver.#getDomain(transfer.from);\n result = result\n .replaceAll(`<domain>`, DownloadFolderResolver.#sanitizePathElement(domain))\n .replaceAll(`<emailfrom>`, DownloadFolderResolver.#sanitizePathElement(transfer.from));\n }\n result = result.replaceAll(`<id>`, transfer.id);\n\n // datesent\n result = result.replace(/<datesent(:(.*?))?>/g, (_0: any, _1: any, dateFormatString: string | undefined): string => {\n const dateFormatted = SimpleDateFormatter.formatDateAndTimeLocal(transfer.sentdate, dateFormatString);\n return DownloadFolderResolver.#sanitizePathElement(DownloadFolderResolver.#pathFriendlyDate(dateFormatted));\n });\n\n if (transfer.message) {\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\n result,\n DownloadFolderResolver.#placeholderRegexForSubstring(`description`),\n transfer.message,\n );\n }\n\n if (transfer.subject) {\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\n result,\n DownloadFolderResolver.#placeholderRegexForSubstring(`subject`),\n transfer.subject,\n );\n }\n\n if (transfer.to && transfer.to.length) {\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\n result,\n DownloadFolderResolver.#placeholderRegexForSubstring(`emailto`),\n transfer.to.join(`,`),\n );\n }\n\n if (transfer.customfields && transfer.customfields.length) {\n for (const cf of transfer.customfields) {\n if (cf.label && cf.value) {\n result = DownloadFolderResolver.#replacePlaceholderWithMaxLength(\n result,\n DownloadFolderResolver.#placeholderRegexForSubstring(cf.label),\n cf.value,\n );\n }\n }\n }\n // remaining custom fields which have not bee replaced from transfer - remove them\n /*\n if (company && company.customfields && company.customfields.length) {\n for (const cf of company.customfields)\n result = result.replace(new RegExp(`<${cf.label}>`, `ig`), ``);\n }\n */\n\n // replace remaining < and > (they are used as placeholder boundaries) and other chars which are not allowed in Windows folder paths\n result = result.replace(/<([^:>]+)(?::([^>]*))?>/g, (_match, name) => {\n // Remove backslashes from the captured name\n const clean = String(name).replace(/\\\\/g, ``);\n return `[missing_${clean}]`;\n });\n\n if (process.platform === `win32`)\n result = DownloadFolderResolver.#trimFolders(result);\n\n return result;\n }\n\n static #trimFolders(template: string) {\n const folders = template.replaceAll(`/`, `\\\\`).split(`\\\\`);\n\n for (let i = 0; i < folders.length; i++)\n folders[i] = folders[i]!.trim();\n\n return folders.join(`\\\\`);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"downloadLogger.js","sourceRoot":"","sources":["../../../src/downloader/downloadLogger.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,2CAA2C,CAAC;AAE7E,MAAM,CAAC,OAAO,OAAO,cAAc;IAC/B,OAAO,CAAS;IAChB,WAAW,CAAkB;IAC7B,WAAW,CAAqB;IAChC,WAAW,CAAqB;IAEhC,YAAY,MAAc,EAAE,UAA2B;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,eAAe,CAAC,EAAU;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,eAAe,CAAC,EAAU;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB,CAAC,cAAwC;QACrD,MAAM,UAAU,GAA4B;YACxC,CAAC,oBAAoB,CAAC,s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,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;IACtG,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,OAAgB,EAAE,IAAU,EAAE,cAAwC;QACzF,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ","sourcesContent":["import type Logger from \"../client/loggers/logger.js\";\r\nimport logEventPropertyName from \"../utils/logging/logEventPropertyNames.js\";\r\n\r\nexport default class DownloadLogger implements Logger {\r\n #logger: Logger;\r\n #trackingId: string | number;\r\n #transferId: string | undefined;\r\n #downloadId: string | undefined;\r\n\r\n constructor(logger: Logger, trackingId: string | number) {\r\n this.#logger = logger;\r\n this.#trackingId = trackingId;\r\n }\r\n\r\n applyTransferId(id: string) {\r\n this.#transferId = id;\r\n }\r\n\r\n applyDownloadId(id: string) {\r\n this.#downloadId = id;\r\n }\r\n\r\n #buildCustomData(additionalArgs?: Record<string, unknown>) {\r\n const customData: Record<string, unknown> = {\r\n [logEventPropertyName.TrackingIdPropertyName]: this.#trackingId,\r\n ...additionalArgs,\r\n };\r\n\r\n if (this.#transferId)\r\n customData[logEventPropertyName.TransferIdPropertyName] = this.#transferId;\r\n\r\n if (this.#downloadId)\r\n customData[logEventPropertyName.DownloadIdPropertyName] = this.#downloadId;\r\n\r\n return customData;\r\n }\r\n\r\n #buildMessage(message: string, json?: any) {\r\n if (json)\r\n return `${message}\\n${JSON.stringify(json, null, 2)}`;\r\n return message;\r\n }\r\n\r\n logTrace(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\r\n this.#logger.logTrace(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\r\n }\r\n\r\n logDebug(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\r\n this.#logger.logDebug(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\r\n }\r\n\r\n logInfo(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\r\n this.#logger.logInfo(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\r\n }\r\n\r\n logWarning(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\r\n this.#logger.logWarning(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\r\n }\r\n\r\n logError(error: Error, message?: string, json?: any, additionalArgs?: Record<string, unknown>) {\r\n const messageToBeLogged = !message ? undefined : this.#buildMessage(message, json);\r\n this.#logger.logError(error, messageToBeLogged, this.#buildCustomData(additionalArgs));\r\n }\r\n}"]}
1
+ {"version":3,"file":"downloadLogger.js","sourceRoot":"","sources":["../../../src/downloader/downloadLogger.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,2CAA2C,CAAC;AAE7E,MAAM,CAAC,OAAO,OAAO,cAAc;IAC/B,OAAO,CAAS;IAChB,WAAW,CAAkB;IAC7B,WAAW,CAAqB;IAChC,WAAW,CAAqB;IAEhC,YAAY,MAAc,EAAE,UAA2B;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,eAAe,CAAC,EAAU;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,eAAe,CAAC,EAAU;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB,CAAC,cAAwC;QACrD,MAAM,UAAU,GAA4B;YACxC,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,EAAE,IAAI,CAAC,WAAW;YAC/D,GAAG,cAAc;SACpB,CAAC;QAEF,IAAI,IAAI,CAA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AC,CAAC,CAAC;IACtG,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,OAAgB,EAAE,IAAU,EAAE,cAAwC;QACzF,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ","sourcesContent":["import type Logger from \"../client/loggers/logger.js\";\nimport logEventPropertyName from \"../utils/logging/logEventPropertyNames.js\";\n\nexport default class DownloadLogger implements Logger {\n #logger: Logger;\n #trackingId: string | number;\n #transferId: string | undefined;\n #downloadId: string | undefined;\n\n constructor(logger: Logger, trackingId: string | number) {\n this.#logger = logger;\n this.#trackingId = trackingId;\n }\n\n applyTransferId(id: string) {\n this.#transferId = id;\n }\n\n applyDownloadId(id: string) {\n this.#downloadId = id;\n }\n\n #buildCustomData(additionalArgs?: Record<string, unknown>) {\n const customData: Record<string, unknown> = {\n [logEventPropertyName.TrackingIdPropertyName]: this.#trackingId,\n ...additionalArgs,\n };\n\n if (this.#transferId)\n customData[logEventPropertyName.TransferIdPropertyName] = this.#transferId;\n\n if (this.#downloadId)\n customData[logEventPropertyName.DownloadIdPropertyName] = this.#downloadId;\n\n return customData;\n }\n\n #buildMessage(message: string, json?: any) {\n if (json)\n return `${message}\\n${JSON.stringify(json, null, 2)}`;\n return message;\n }\n\n logTrace(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\n this.#logger.logTrace(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\n }\n\n logDebug(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\n this.#logger.logDebug(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\n }\n\n logInfo(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\n this.#logger.logInfo(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\n }\n\n logWarning(message: string, json?: any, additionalArgs?: Record<string, unknown>) {\n this.#logger.logWarning(this.#buildMessage(message, json), this.#buildCustomData(additionalArgs));\n }\n\n logError(error: Error, message?: string, json?: any, additionalArgs?: Record<string, unknown>) {\n const messageToBeLogged = !message ? undefined : this.#buildMessage(message, json);\n this.#logger.logError(error, messageToBeLogged, this.#buildCustomData(additionalArgs));\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"downloadOptions.js","sourceRoot":"","sources":["../../../src/downloader/downloadOptions.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe;IACjB;;;OAGG;IACH,UAAU,GAAkB,IAAI,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,sBAAsB,GAAkB,IAAI,CAAC;IAC7C;;;;OAIG;IACH,cAAc,GAAkB,IAAI,CAAC;IACrC;;;OAGG;IACH,0BAA0B,GAAG,KAAK,CAAC;IACnC;;;;OAIG;IACH,aAAa,GAAG,CAAC,CAAC;IAClB;;;;;OAKG;IACH,cAAc,GAAG,CAAC,CAAC;IACnB;;;OAGG;IACH,gBAAgB,GAAG,EAAE,CAAC;IACtB;;;OAGG;IACH,SAAS,GAAkB,IAAI,CAAC;IAChC;;;OAGG;IACH,YAAY,GAAkB,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,cAAc,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,YAAY,GAAG,KAAK,CAAC;IACrB;;;OAGG;IACH,4BAA4B,GAAG,KAAK,CAAC;IACrC;;;;;OAKG;IACH,sBAAsB,GAAG,CAAC,CAAC;IAC3B;;;;OAIG;IACH,yCAAyC,GAAG,EAAE,CAAC;IAC/C;;;;;OAKG;IACH,oCAAoC,GAAG,IAAI,CAAC;IAC5C;;;OAGG;IACH,kBAAkB,GAAG,GAAG,CAAC;IACzB;;;OAGG;IACH,yBAAyB,GAAG,IAAI,CAAC;IACjC;;;OAGG;IACH,8BAA8B,GAAG,IAAI,CAAC;IACtC;;;;;OAKG;IACH,uCAAuC,GAAG,KAAK,CAAC;IAChD;;;;;;OAMG;IACH,0BAA0B,GAAkB,IAAI,CAAC;IACjD;;;OAGG;IACH,8BAA8B,GAAG,IAAI,CAAC;IACtC;;;OAGG;IACH,oCAAoC,GAAG,IAAI,CAAC;IAC5C;;OAEG;IACH,UAAU,CAA8B;IACxC;;;OAGG;IACH,gBAAgB,GAAG,KAAK,CAAC;CAC5B;AAED,eAAe,eAAe,CAAC","sourcesContent":["class DownloadOptions {\r\n /**\r\n * logintoken of the current user - used to fetch transfer (optionally also pwd-protected), company setup, register download\r\n * @default null\r\n */\r\n logintoken: string | null = null;\r\n /**\r\n * Path template where files should be downloaded. Provide this OR {@link downloadFolder}. Supports placeholders:\r\n * <id> - transferId\r\n * <subject>\r\n * <description>\r\n * <domain> - domain based on \"from\" email (e.g. user@example.com --> example.com)\r\n * <emailfrom>\r\n * <datesent> - will be formatted as \"YYYY-MM-DD-hh-mm\"\r\n * <datesent:format> - will be formatted according to \"format\"; supported placeholders in \"format\": YYYY, MM, DD, hh, mm\r\n * <emailto> - all recipients emails comma-separated\r\n * <{custom_field_label}> - specified custom field named by label will replaced with that custom field's value\r\n * @default null\r\n */\r\n downloadFolderTemplate: string | null = null;\r\n /**\r\n * The path where files should be downloaded. No placeholders. Provide this OR {@link downloadFolderTemplate}.\r\n * When {@link downloadFolderTemplate} is specified this value will be overwritten with the resolved (final) path.\r\n * @default null\r\n */\r\n downloadFolder: string | null = null;\r\n /**\r\n * HTTP request timeout for web api (not Fileserver) in milliseconds.\r\n * @default 60000\r\n */\r\n apiRequestTotalTimeoutInMs = 60000;\r\n /**\r\n * How many times to attempt HTTP requests towards web API (not Fileserver) e.g. when getting a transfer from the API.\r\n * @see https://github.com/sindresorhus/got#documentation\r\n * @default 3\r\n */\r\n apiRetryLimit = 3;\r\n /**\r\n * Maximum number (N) of chunks that can be downloaded in parallel. As soon as any single chunk is complete then next available chunk is started (to keep parallel chunks always at N).\r\n * - If there is one huge file with X chunks (X>N) - first N chunks will be picked up.\r\n * - If there are 2 files, each with 3 chunks and N=4 - both files will be started (all 3 chunks of first file and only 1st chunk of the 2nd file).\r\n * @default 8\r\n */\r\n parallelChunks = 8;\r\n /**\r\n * How many times to try write downloaded bytes of a chunk and optionally verify its MD5. Set to -1 to keep trying forever.\r\n * @default 20\r\n */\r\n maxWriteAttempts = 20;\r\n /**\r\n * The user-agent header that will be used for all fileserver GetFile requests.\r\n * @default null\r\n */\r\n userAgent: string | null = null;\r\n /**\r\n * Maximum size (S) of a chunk in bytes. When set to a number - downloader will split files into chunks of this size (size of last chunk) <= S. Set to null to download every file in one HTTPS request.\r\n * @default 50 * 1024 * 1024 (50MB) - this matches the default pre-calculated rangehashes on Fileservers.\r\n */\r\n maxChunkSize: number | null = 50 * 1024 * 1024;\r\n /**\r\n * When set to **true** downloader will verify MD5 after every chunk. This doesn't work for end to end encrypted transfers.\r\n * @efault true\r\n */\r\n checkChunksMd5 = true;\r\n /**\r\n * When set to **true** downloader will verify MD5 for every completed file (entire file). To use this feature provided the MD5 value in DownloadFileInfo passed to the downloader. This doesn't work for end to end encrypted transfers.\r\n * @note NOT SUPPORTED (YET)\r\n */\r\n checkFileMd5 = false;\r\n /**\r\n * How long should it take for HTTP library to throw error when no download data is pumped to response (milliseconds).\r\n * @default 30000\r\n */\r\n fileserverDownloadIdleTimeMs = 30000;\r\n /**\r\n * How many times to attempt a single HTTP download request against Fileserver's GetFile. Set this options to 0 to keep trying forever.\r\n * When set to 0 (retring forever) the downloader will report \"network problem\" after 10 failed attempts (via event and a status field).\r\n * When connectivity is back it will be reported with an event as well.\r\n * @default 0\r\n */\r\n fileserverAttemptLimit = 0;\r\n /**\r\n * Downloader will assume there is a \"network problem\" after this many consecutive network errors without any successful progress.\r\n * Set to -1 to disable this feature.\r\n * @default 10;\r\n */\r\n fileserverOfflineAfterConsecutiveAttempts = 10;\r\n /**\r\n * Once downloader sees a \"network problem\" it will retry every pending chunk with this interval (in milliseconds).\r\n * This interval will be also used to calculate exponential backoff between first network error and getting into \"network problem\" state\r\n * and also is the maximum interval of the exponential backoff.\r\n * @default 5000;\r\n */\r\n fileserverOfflineCheckIntervalMillis = 5000;\r\n /**\r\n * Number of milliseconds between progress events emitted by the downloader (throttling - they won't be emitted more often that this amount of time).\r\n * @default 100\r\n */\r\n progressTickMillis = 100;\r\n /**\r\n * If set to **true** ==> the downloader will delete those files which were being downloaded, but failed.\r\n * @default true\r\n */\r\n deleteFailedFilesFromDisk = true;\r\n /**\r\n * When set to **true** ==> after user requests download abort - the downloader will delete all files which it tried to download, no matter their size and status.\r\n * @default true\r\n */\r\n deleteAbortedDownloadsFromDisk = true;\r\n /**\r\n * When set to **true** ==> after download completes or is aborted - the downloader will delete the main download folder if it is empty (no files have been downloaded and there are no other files left over).\r\n * Default is false as usually the download folder is set to be the OS-special (e.g. on windows --> c:\\users\\jane\\Downloads). We don't want to try removing that.\r\n * Set this to **true** only if specifying custom download folders.\r\n * @default false\r\n */\r\n deleteEmptyDownloadFoldersAfterDownload = false;\r\n /**\r\n * When this path is specified (not null) then downloader will track download progress of each file within this folder.\r\n * Every download gets own subfolder (transferID_downloadID) with dumped options of the download (options.json) and files.json\r\n * which tracks all pending files. It will not contain completed files or those that have not started yet. Tracking is performed with\r\n * chunk-precision (not byte-precision). Worst case the download tracker may lose N chunks (N being the number of {@link parallelChunks}).\r\n * @default null\r\n */\r\n downloadTrackingBaseFolder: string | null = null;\r\n /**\r\n * Minimum time interval (in milliseconds) between consecutive dumps of downloader state to disk.\r\n * @default 5000\r\n */\r\n downloadTrackingIntervalMillis = 5000;\r\n /**\r\n * Time window length (in milliseconds) over which the downloader calculates momentary download speed.\r\n * @default 2000\r\n */\r\n momentaryDownloadSpeedTimespanMillis = 2000;\r\n /**\r\n * A value that will be appended to all log events.\r\n */\r\n trackingId: number | string | undefined;\r\n /**\r\n * Skips download registration if set to true\r\n * @default false\r\n */\r\n skipRegistration = false;\r\n}\r\n\r\nexport default DownloadOptions;"]}
1
+ {"version":3,"file":"downloadOptions.js","sourceRoot":"","sources":["../../../src/downloader/downloadOptions.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe;IACjB;;;OAGG;IACH,UAAU,GAAkB,IAAI,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,sBAAsB,GAAkB,IAAI,CAAC;IAC7C;;;;OAIG;IACH,cAAc,GAAkB,IAAI,CAAC;IACrC;;;OAGG;IACH,0BAA0B,GAAG,KAAK,CAAC;IACnC;;;;OAIG;IACH,aAAa,GAAG,CAAC,CAAC;IAClB;;;;;OAKG;IACH,cAAc,GAAG,CAAC,CAAC;IACnB;;;OAGG;IACH,gBAAgB,GAAG,EAAE,CAAC;IACtB;;;OAGG;IACH,SAAS,GAAkB,IAAI,CAAC;IAChC;;;OAGG;IACH,YAAY,GAAkB,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,cAAc,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,YAAY,GAAG,KAAK,CAAC;IACrB;;;OAGG;IACH,4BAA4B,GAAG,KAAK,CAAC;IACrC;;;;;OAKG;IACH,sBAAsB,GAAG,CAAC,CAAC;IAC3B;;;;OAIG;IACH,yCAAyC,GAAG,EAAE,CAAC;IAC/C;;;;;OAKG;IACH,oCAAoC,GAAG,IAAI,CAAC;IAC5C;;;OAGG;IACH,kBAAkB,GAAG,GAAG,CAAC;IACzB;;;OAGG;IACH,yBAAyB,GAAG,IAAI,CAAC;IACjC;;;OAGG;IACH,8BAA8B,GAAG,IAAI,CAAC;IACtC;;;;;OAKG;IACH,uCAAuC,GAAG,KAAK,CAAC;IAChD;;;;;;OAMG;IACH,0BAA0B,GAAkB,IAAI,CAAC;IACjD;;;OAGG;IACH,8BAA8B,GAAG,IAAI,CAAC;IACtC;;;OAGG;IACH,oCAAoC,GAAG,IAAI,CAAC;IAC5C;;OAEG;IACH,UAAU,CAA8B;IACxC;;;OAGG;IACH,gBAAgB,GAAG,KAAK,CAAC;CAC5B;AAED,eAAe,eAAe,CAAC","sourcesContent":["class DownloadOptions {\n /**\n * logintoken of the current user - used to fetch transfer (optionally also pwd-protected), company setup, register download\n * @default null\n */\n logintoken: string | null = null;\n /**\n * Path template where files should be downloaded. Provide this OR {@link downloadFolder}. Supports placeholders:\n * <id> - transferId\n * <subject>\n * <description>\n * <domain> - domain based on \"from\" email (e.g. user@example.com --> example.com)\n * <emailfrom>\n * <datesent> - will be formatted as \"YYYY-MM-DD-hh-mm\"\n * <datesent:format> - will be formatted according to \"format\"; supported placeholders in \"format\": YYYY, MM, DD, hh, mm\n * <emailto> - all recipients emails comma-separated\n * <{custom_field_label}> - specified custom field named by label will replaced with that custom field's value\n * @default null\n */\n downloadFolderTemplate: string | null = null;\n /**\n * The path where files should be downloaded. No placeholders. Provide this OR {@link downloadFolderTemplate}.\n * When {@link downloadFolderTemplate} is specified this value will be overwritten with the resolved (final) path.\n * @default null\n */\n downloadFolder: string | null = null;\n /**\n * HTTP request timeout for web api (not Fileserver) in milliseconds.\n * @default 60000\n */\n apiRequestTotalTimeoutInMs = 60000;\n /**\n * How many times to attempt HTTP requests towards web API (not Fileserver) e.g. when getting a transfer from the API.\n * @see https://github.com/sindresorhus/got#documentation\n * @default 3\n */\n apiRetryLimit = 3;\n /**\n * Maximum number (N) of chunks that can be downloaded in parallel. As soon as any single chunk is complete then next available chunk is started (to keep parallel chunks always at N).\n * - If there is one huge file with X chunks (X>N) - first N chunks will be picked up.\n * - If there are 2 files, each with 3 chunks and N=4 - both files will be started (all 3 chunks of first file and only 1st chunk of the 2nd file).\n * @default 8\n */\n parallelChunks = 8;\n /**\n * How many times to try write downloaded bytes of a chunk and optionally verify its MD5. Set to -1 to keep trying forever.\n * @default 20\n */\n maxWriteAttempts = 20;\n /**\n * The user-agent header that will be used for all fileserver GetFile requests.\n * @default null\n */\n userAgent: string | null = null;\n /**\n * Maximum size (S) of a chunk in bytes. When set to a number - downloader will split files into chunks of this size (size of last chunk) <= S. Set to null to download every file in one HTTPS request.\n * @default 50 * 1024 * 1024 (50MB) - this matches the default pre-calculated rangehashes on Fileservers.\n */\n maxChunkSize: number | null = 50 * 1024 * 1024;\n /**\n * When set to **true** downloader will verify MD5 after every chunk. This doesn't work for end to end encrypted transfers.\n * @efault true\n */\n checkChunksMd5 = true;\n /**\n * When set to **true** downloader will verify MD5 for every completed file (entire file). To use this feature provided the MD5 value in DownloadFileInfo passed to the downloader. This doesn't work for end to end encrypted transfers.\n * @note NOT SUPPORTED (YET)\n */\n checkFileMd5 = false;\n /**\n * How long should it take for HTTP library to throw error when no download data is pumped to response (milliseconds).\n * @default 30000\n */\n fileserverDownloadIdleTimeMs = 30000;\n /**\n * How many times to attempt a single HTTP download request against Fileserver's GetFile. Set this options to 0 to keep trying forever.\n * When set to 0 (retring forever) the downloader will report \"network problem\" after 10 failed attempts (via event and a status field).\n * When connectivity is back it will be reported with an event as well.\n * @default 0\n */\n fileserverAttemptLimit = 0;\n /**\n * Downloader will assume there is a \"network problem\" after this many consecutive network errors without any successful progress.\n * Set to -1 to disable this feature.\n * @default 10;\n */\n fileserverOfflineAfterConsecutiveAttempts = 10;\n /**\n * Once downloader sees a \"network problem\" it will retry every pending chunk with this interval (in milliseconds).\n * This interval will be also used to calculate exponential backoff between first network error and getting into \"network problem\" state\n * and also is the maximum interval of the exponential backoff.\n * @default 5000;\n */\n fileserverOfflineCheckIntervalMillis = 5000;\n /**\n * Number of milliseconds between progress events emitted by the downloader (throttling - they won't be emitted more often that this amount of time).\n * @default 100\n */\n progressTickMillis = 100;\n /**\n * If set to **true** ==> the downloader will delete those files which were being downloaded, but failed.\n * @default true\n */\n deleteFailedFilesFromDisk = true;\n /**\n * When set to **true** ==> after user requests download abort - the downloader will delete all files which it tried to download, no matter their size and status.\n * @default true\n */\n deleteAbortedDownloadsFromDisk = true;\n /**\n * When set to **true** ==> after download completes or is aborted - the downloader will delete the main download folder if it is empty (no files have been downloaded and there are no other files left over).\n * Default is false as usually the download folder is set to be the OS-special (e.g. on windows --> c:\\users\\jane\\Downloads). We don't want to try removing that.\n * Set this to **true** only if specifying custom download folders.\n * @default false\n */\n deleteEmptyDownloadFoldersAfterDownload = false;\n /**\n * When this path is specified (not null) then downloader will track download progress of each file within this folder.\n * Every download gets own subfolder (transferID_downloadID) with dumped options of the download (options.json) and files.json\n * which tracks all pending files. It will not contain completed files or those that have not started yet. Tracking is performed with\n * chunk-precision (not byte-precision). Worst case the download tracker may lose N chunks (N being the number of {@link parallelChunks}).\n * @default null\n */\n downloadTrackingBaseFolder: string | null = null;\n /**\n * Minimum time interval (in milliseconds) between consecutive dumps of downloader state to disk.\n * @default 5000\n */\n downloadTrackingIntervalMillis = 5000;\n /**\n * Time window length (in milliseconds) over which the downloader calculates momentary download speed.\n * @default 2000\n */\n momentaryDownloadSpeedTimespanMillis = 2000;\n /**\n * A value that will be appended to all log events.\n */\n trackingId: number | string | undefined;\n /**\n * Skips download registration if set to true\n * @default false\n */\n skipRegistration = false;\n}\n\nexport default DownloadOptions;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"downloadFileChunkProgress.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFileChunkProgress.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,yBAAyB;IAC1C,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,KAAK,CAAgB;IACrB,GAAG,CAAgB;IACnB,IAAI,CAAS;IACb,UAAU,CAAS;IACnB,OAAO,CAAS;IAChB,SAAS,CAAU;IACnB,MAAM,CAAU;IAEhB,YAAY,EAAU,EAAE,WAAmB,EAAE,KAAoB,EAAE,GAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,OAAe,EAAE,SAAkB,EAAE,MAAe;QACzK,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,KAA4B;QACpD,OAAO,IAAI,yBAAyB,CAChC,KAAK,CAAC,EAAE,EACR,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,eAAe,EACrB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,QAAQ,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type DownloadFileChunkInfo from \"../dtos/downloadFileChunkInfo.js\";\r\n\r\nexport default class DownloadFileChunkProgress {\r\n id: string;\r\n chunkNumber: number;\r\n start: number | null;\r\n end: number | null;\r\n size: number;\r\n downloaded: number;\r\n percent: number;\r\n completed: boolean;\r\n failed: boolean;\r\n\r\n constructor(id: string, chunkNumber: number, start: number | null, end: number | null, size: number, downloaded: number, percent: number, completed: boolean, failed: boolean) {\r\n this.id = id;\r\n this.chunkNumber = chunkNumber;\r\n this.start = start;\r\n this.end = end;\r\n this.size = size;\r\n this.downloaded = downloaded;\r\n this.percent = percent;\r\n this.completed = completed;\r\n this.failed = failed;\r\n }\r\n\r\n public static FromChunkInfo(chunk: DownloadFileChunkInfo): DownloadFileChunkProgress {\r\n return new DownloadFileChunkProgress(\r\n chunk.id,\r\n chunk.chunkNumber,\r\n chunk.start,\r\n chunk.end,\r\n chunk.chunkSize,\r\n chunk.downloadedBytes,\r\n chunk.percent,\r\n chunk.isCompleted,\r\n chunk.isFailed,\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"downloadFileChunkProgress.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFileChunkProgress.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,yBAAyB;IAC1C,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,KAAK,CAAgB;IACrB,GAAG,CAAgB;IACnB,IAAI,CAAS;IACb,UAAU,CAAS;IACnB,OAAO,CAAS;IAChB,SAAS,CAAU;IACnB,MAAM,CAAU;IAEhB,YAAY,EAAU,EAAE,WAAmB,EAAE,KAAoB,EAAE,GAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,OAAe,EAAE,SAAkB,EAAE,MAAe;QACzK,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,KAA4B;QACpD,OAAO,IAAI,yBAAyB,CAChC,KAAK,CAAC,EAAE,EACR,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,eAAe,EACrB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,QAAQ,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type DownloadFileChunkInfo from \"../dtos/downloadFileChunkInfo.js\";\n\nexport default class DownloadFileChunkProgress {\n id: string;\n chunkNumber: number;\n start: number | null;\n end: number | null;\n size: number;\n downloaded: number;\n percent: number;\n completed: boolean;\n failed: boolean;\n\n constructor(id: string, chunkNumber: number, start: number | null, end: number | null, size: number, downloaded: number, percent: number, completed: boolean, failed: boolean) {\n this.id = id;\n this.chunkNumber = chunkNumber;\n this.start = start;\n this.end = end;\n this.size = size;\n this.downloaded = downloaded;\n this.percent = percent;\n this.completed = completed;\n this.failed = failed;\n }\n\n public static FromChunkInfo(chunk: DownloadFileChunkInfo): DownloadFileChunkProgress {\n return new DownloadFileChunkProgress(\n chunk.id,\n chunk.chunkNumber,\n chunk.start,\n chunk.end,\n chunk.chunkSize,\n chunk.downloadedBytes,\n chunk.percent,\n chunk.isCompleted,\n chunk.isFailed,\n );\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"downloadFileProgress.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFileProgress.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACrC,EAAE,CAAS;IACX,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,YAAY,CAAS;IACrB,qBAAqB,CAAgB;IACrC,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,MAAM,CAAU;IAChB,QAAQ,GAAyB,EAAE,CAAC;IACpC,MAAM,CAAS;IACf,WAAW,CAAgB;IAE3B,YACI,UAAkB,EAClB,IAAY,EACZ,GAAW,EACX,YAAoB,EACpB,qBAAoC,EACpC,IAAY,EACZ,UAAkB,EAClB,OAAe,EACf,SAAkB,EAClB,MAAe,EACf,QAAqC,EACrC,cAAsB,EACtB,mBAAkC;QAElC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC;QACvC,IAAI,QAAQ;YACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,oBAAoB,CAAC,IAAsB;QACrD,OAAO,IAAI,oBAAoB,CAC3B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,IAAI,CAAC,yBAAyB,CACjC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type DownloadError from \"../dtos/downloadError.js\";\r\nimport type DownloadFileInfo from \"../dtos/downloadFileInfo.js\";\r\n\r\nexport default class DownloadFileProgress {\r\n id: string;\r\n name: string;\r\n url: string;\r\n downloadPath: string;\r\n temporaryDownloadPath: string | null;\r\n percent: number;\r\n downloaded: number;\r\n size: number;\r\n completed: boolean;\r\n failed: boolean;\r\n failures: Array<DownloadError> = [];\r\n chunks: number;\r\n lastOkChunk: number | null;\r\n\r\n constructor(\r\n externalId: string,\r\n name: string,\r\n url: string,\r\n downloadPath: string,\r\n temporaryDownloadPath: string | null,\r\n size: number,\r\n downloaded: number,\r\n percent: number,\r\n completed: boolean,\r\n failed: boolean,\r\n failures: Array<DownloadError> | null,\r\n numberOfChunks: number,\r\n lastSuccessfulChunk: number | null,\r\n ) {\r\n this.id = externalId;\r\n this.name = name;\r\n this.url = url;\r\n this.downloadPath = downloadPath;\r\n this.temporaryDownloadPath = temporaryDownloadPath;\r\n this.size = size;\r\n this.downloaded = downloaded;\r\n this.percent = percent;\r\n this.completed = completed;\r\n this.failed = failed;\r\n this.chunks = numberOfChunks;\r\n this.lastOkChunk = lastSuccessfulChunk;\r\n if (failures)\r\n this.failures = failures.slice();\r\n }\r\n\r\n public static FromFileDownloadInfo(file: DownloadFileInfo): DownloadFileProgress {\r\n return new DownloadFileProgress(\r\n file.externalId,\r\n file.name,\r\n file.url,\r\n file.downloadPath,\r\n file.temporaryDownloadPath,\r\n file.sizeInBytes,\r\n file.downloadedBytes,\r\n file.percent,\r\n file.isCompleted,\r\n file.isFailed,\r\n file.failures,\r\n file.chunks.length,\r\n file.lastSuccessfulChunkNumber,\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"downloadFileProgress.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFileProgress.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACrC,EAAE,CAAS;IACX,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,YAAY,CAAS;IACrB,qBAAqB,CAAgB;IACrC,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,MAAM,CAAU;IAChB,QAAQ,GAAyB,EAAE,CAAC;IACpC,MAAM,CAAS;IACf,WAAW,CAAgB;IAE3B,YACI,UAAkB,EAClB,IAAY,EACZ,GAAW,EACX,YAAoB,EACpB,qBAAoC,EACpC,IAAY,EACZ,UAAkB,EAClB,OAAe,EACf,SAAkB,EAClB,MAAe,EACf,QAAqC,EACrC,cAAsB,EACtB,mBAAkC;QAElC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC;QACvC,IAAI,QAAQ;YACR,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,oBAAoB,CAAC,IAAsB;QACrD,OAAO,IAAI,oBAAoB,CAC3B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,IAAI,CAAC,yBAAyB,CACjC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type DownloadError from \"../dtos/downloadError.js\";\nimport type DownloadFileInfo from \"../dtos/downloadFileInfo.js\";\n\nexport default class DownloadFileProgress {\n id: string;\n name: string;\n url: string;\n downloadPath: string;\n temporaryDownloadPath: string | null;\n percent: number;\n downloaded: number;\n size: number;\n completed: boolean;\n failed: boolean;\n failures: Array<DownloadError> = [];\n chunks: number;\n lastOkChunk: number | null;\n\n constructor(\n externalId: string,\n name: string,\n url: string,\n downloadPath: string,\n temporaryDownloadPath: string | null,\n size: number,\n downloaded: number,\n percent: number,\n completed: boolean,\n failed: boolean,\n failures: Array<DownloadError> | null,\n numberOfChunks: number,\n lastSuccessfulChunk: number | null,\n ) {\n this.id = externalId;\n this.name = name;\n this.url = url;\n this.downloadPath = downloadPath;\n this.temporaryDownloadPath = temporaryDownloadPath;\n this.size = size;\n this.downloaded = downloaded;\n this.percent = percent;\n this.completed = completed;\n this.failed = failed;\n this.chunks = numberOfChunks;\n this.lastOkChunk = lastSuccessfulChunk;\n if (failures)\n this.failures = failures.slice();\n }\n\n public static FromFileDownloadInfo(file: DownloadFileInfo): DownloadFileProgress {\n return new DownloadFileProgress(\n file.externalId,\n file.name,\n file.url,\n file.downloadPath,\n file.temporaryDownloadPath,\n file.sizeInBytes,\n file.downloadedBytes,\n file.percent,\n file.isCompleted,\n file.isFailed,\n file.failures,\n file.chunks.length,\n file.lastSuccessfulChunkNumber,\n );\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"downloadFilePromise.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFilePromise.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,CAAS;IAChB,QAAQ,CAAkB;IAC1B,QAAQ,GAAgE,SAAS,CAAC;IAElF,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE;YAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC5B,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,QAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ","sourcesContent":["export default class DownloadFilePromise {\r\n #fileId: string;\r\n #promise: Promise<string>;\r\n #resolve: ((value: string | PromiseLike<string>) => void) | undefined = undefined;\r\n\r\n constructor(fileId: string) {\r\n this.#fileId = fileId;\r\n this.#promise = new Promise<string>(resolve => {\r\n this.#resolve = resolve;\r\n });\r\n }\r\n\r\n complete(): void {\r\n this.#resolve!(this.#fileId);\r\n }\r\n\r\n get awaiter(): Promise<string> {\r\n return this.#promise;\r\n }\r\n}"]}
1
+ {"version":3,"file":"downloadFilePromise.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadFilePromise.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,CAAS;IAChB,QAAQ,CAAkB;IAC1B,QAAQ,GAAgE,SAAS,CAAC;IAElF,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE;YAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC5B,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,QAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ","sourcesContent":["export default class DownloadFilePromise {\n #fileId: string;\n #promise: Promise<string>;\n #resolve: ((value: string | PromiseLike<string>) => void) | undefined = undefined;\n\n constructor(fileId: string) {\n this.#fileId = fileId;\n this.#promise = new Promise<string>(resolve => {\n this.#resolve = resolve;\n });\n }\n\n complete(): void {\n this.#resolve!(this.#fileId);\n }\n\n get awaiter(): Promise<string> {\n return this.#promise;\n }\n}"]}
@@ -29,6 +29,7 @@ export default class DownloadState {
29
29
  aborted(): boolean;
30
30
  fileStarting(file: DownloadFileInfo): void;
31
31
  fileCreating(file: DownloadFileInfo): void;
32
+ ensureFileStarted(file: DownloadFileInfo): void;
32
33
  fileCreated(file: DownloadFileInfo): void;
33
34
  fileFailedById(fileId: string, reason: DownloadError): void;
34
35
  fileFailed(file: DownloadFileInfo, reason: DownloadError): void;
@@ -1 +1 @@
1
- {"version":3,"file":"downloadState.d.ts","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadState.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,qCAAqC,CAAC;AAEjE,OAAO,aAAa,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,gBAAgB,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,qBAAqB,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,iBAAiB,MAAM,mCAAmC,CAAC;AAOvE,OAAO,KAAK,kBAAkB,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,uBAAuB,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AAGzD,MAAM,CAAC,OAAO,OAAO,aAAa;;gBAsClB,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,uBAAuB;IAoB5K,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,MAAM,IAAI,cAAc,CAE3B;IAED,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,IAAI,yBAAyB,IAAI,OAAO,CAEvC;IAED,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAED,IAAI,qBAAqB,IAAI,OAAO,CAEnC;IAED,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED,IAAI,YAAY,IAAI,iBAAiB,CAEpC;IAgCD,KAAK,IAAI,OAAO;IAYhB,YAAY,CAAC,OAAO,EAAE;QAA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AE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAyElE"}
@@ -197,6 +197,10 @@ export default class DownloadState {
197
197
  const args = this.#buildFileDownloadEventArgs(file);
198
198
  this.#eventsEngine.emit(TransferDownloadEvent.FileCreating, args);
199
199
  }
200
+ ensureFileStarted(file) {
201
+ if (!file.isStarted)
202
+ this.#fileStarted(file);
203
+ }
200
204
  fileCreated(file) {
201
205
  const args = this.#buildFileDownloadEventArgs(file);
202
206
  this.#eventsEngine.emit(TransferDownloadEvent.FileCreated, args);
@@ -1 +1 @@
1
- {"version":3,"file":"downloadState.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadState.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AAiBvE,MAAM,CAAC,OAAO,OAAO,aAAa;IACrB,WAAW,CAAS;IACpB,WAAW,CAAS;IACpB,QAAQ,CAAkB;IAC1B,aAAa,CAAe;IAE5B,MAAM,CAA0B;IAChC,YAAY,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAClE,aAAa,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAE5E,UAAU,GAAG,CAAC,CAAC;IACf,cAAc,GAAG,IAAI,CAAC;IACtB,yBAAyB,GAAG,CAAC,CAAC;IAC9B,OAAO,GAAmB,cAAc,CAAC,WAAW,CAAC;IACrD,4BAA4B,GAAkB,IAAI,CAAC;IACnD,uBAAuB,GAAkB,IAAI,CAAC;IAC9C,oBAAoB,GAAG,CAAC,CAAC;IACzB,gCAAgC,GAAkB,IAAI,CAAC;IACvD,cAAc,GAAkB,IAAI,CAAC;IACrC,QAAQ,GAAG,CAAC,CAAC;IAEb;;OAEG;IACH,qBAAqB,GAAG,CAAC,CAA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AC;gBACvC,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC;gBACxE,IAAI,IAAI,CAAC,8BAA8B;oBACnC,IAAI,CAAC,8BAA8B,GAAG,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,8BAA8B,CAAC,CAAC;;oBAEzG,IAAI,CAAC,8BAA8B,GAAG,YAAY,CAAC;YAC3D,CAAC;QACL,CAAC;IACL,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,eAAe;QACX,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,YAAY;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,gBAAgB,CAAC,IAAsB;QACnC,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,iBAAiB,CAAC,KAA4B;QAC1C,OAAO,yBAAyB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;CACJ","sourcesContent":["import TransferStatus from \"../../utils/types/transferStatus.js\";\r\nimport TransferDownloadEvent from \"../dtos/downloadEvent.js\";\r\nimport DownloadError from \"../dtos/downloadError.js\";\r\nimport DownloadFileProgress from \"./downloadFileProgress.js\";\r\nimport DownloadFileChunkProgress from \"./downloadFileChunkProgress.js\";\r\n\r\nimport type DownloadFileInfo from \"../dtos/downloadFileInfo.js\";\r\nimport type DownloadFileChunkInfo from \"../dtos/downloadFileChunkInfo.js\";\r\nimport type EventsEngine from \"../../utils/events/eventsEngine.js\";\r\nimport type DownloadEventArgs from \"../eventArgs/downloadEventArgs.js\";\r\nimport type DownloadCompletedEventArgs from \"../eventArgs/downloadCompletedEventArgs.js\";\r\nimport type DownloadPauseEventArgs from \"../eventArgs/downloadPauseEventArgs.js\";\r\nimport type FileDownloadEventArgs from \"../eventArgs/fileDownloadEventArgs.js\";\r\nimport type FileDownloadFailedEventArgs from \"../eventArgs/fileDownloadFailedEventArgs.js\";\r\nimport type ChunkDownloadEventArgs from \"../eventArgs/chunkDownloadEventArgs.js\";\r\nimport type ChunkDownloadFailedEventArgs from \"../eventArgs/chunkDownloadFailedEventArgs.js\";\r\nimport type ChunkProgressEvent from \"../../utils/events/chunkProgressEvent.js\";\r\nimport type DownloaderRestoredState from \"../dtos/downloaderRestoredState.js\";\r\nimport type DownloadOptions from \"../downloadOptions.js\";\r\nimport type DownloadMetadataDeterminedEventArgs from \"../eventArgs/downloadMetadataDeterminedEventArgs.js\";\r\n\r\nexport default class DownloadState {\r\n readonly #transferId: string;\r\n readonly #downloadId: string;\r\n readonly #options: DownloadOptions;\r\n readonly #eventsEngine: EventsEngine;\r\n\r\n readonly #files: Array<DownloadFileInfo>;\r\n readonly #failedFiles: Set<DownloadFileInfo> = new Set<DownloadFileInfo>();\r\n readonly #pendingFiles: Set<DownloadFileInfo> = new Set<DownloadFileInfo>();\r\n\r\n #totalSize = 0;\r\n #networkStatus = true;\r\n #consecutiveNetworkErrors = 0;\r\n #status: TransferStatus = TransferStatus.Initialized;\r\n #firstStartedUnixEpochMillis: number | null = null;\r\n #startedUnixEpochMillis: number | null = null;\r\n #elapsedActiveMillis = 0;\r\n #lastProgressTickUnixEpochMillis: number | null = null;\r\n #lastSpeedCalc: number | null = null;\r\n #percent = 0;\r\n\r\n /**\r\n * How many bytes downloaded - counting only completed files.\r\n */\r\n #downloadedBytes_bank = 0;\r\n /**\r\n * How many bytes downloaded total (bank + pendingFiles).\r\n */\r\n #downloadedBytes = 0;\r\n\r\n #bytesPerSecondAverage = 0;\r\n #bytesPerSecondCurrent = 0;\r\n #currentSpeedMeasurementDownloadedBytes: Array<{ time: number, bytes: number }> = [];\r\n #estimatedRemainingTimeSeconds: number | null = null;\r\n #pauseImmediately = false;\r\n #pausedTrigger?: (pauseTriggered: boolean) => void;\r\n #resumeResolve?: (status: TransferStatus) => void;\r\n\r\n constructor(downloadId: string, transferId: string, files: Array<DownloadFileInfo>, options: DownloadOptions, eventsEngine: EventsEngine, oldState?: DownloaderRestoredState) {\r\n this.#downloadId = downloadId;\r\n this.#transferId = transferId;\r\n this.#eventsEngine = eventsEngine;\r\n this.#files = files;\r\n this.#options = options;\r\n\r\n if (oldState) {\r\n this.#elapsedActiveMillis = oldState.activeTime;\r\n this.#downloadedBytes = oldState.downloadedBytes;\r\n this.#downloadedBytes_bank = oldState.downloadedBytesBank;\r\n this.#totalSize = oldState.totalSize;\r\n this.#percent = oldState.percent;\r\n }\r\n else {\r\n for (const file of this.#files)\r\n this.#totalSize += file.sizeInBytes;\r\n }\r\n }\r\n\r\n get isRunning(): boolean {\r\n return this.#status === TransferStatus.Running;\r\n }\r\n\r\n get status(): TransferStatus {\r\n return this.#status;\r\n }\r\n\r\n get hasFailedFiles(): boolean {\r\n return this.#failedFiles.size > 0;\r\n }\r\n\r\n get allFilesCompletedOrFailed(): boolean {\r\n return this.#files.every(x => x.isCompleted || x.isFailed);\r\n }\r\n\r\n get averageBytesPerSecond(): number {\r\n return this.#bytesPerSecondAverage;\r\n }\r\n\r\n get isThereNetworkProblem(): boolean {\r\n return this.#networkStatus === false;\r\n }\r\n\r\n get pauseImmediately(): boolean {\r\n return this.#pauseImmediately;\r\n }\r\n\r\n get currentState(): DownloadEventArgs {\r\n return this.#buildDownloadEventArgs();\r\n }\r\n\r\n get #nowUnixEpochMillis() {\r\n return new Date().getTime();\r\n }\r\n\r\n get #activeTimeMillis() {\r\n return this.#elapsedActiveMillis + this.#activeTimeMillisSinceLastStart;\r\n }\r\n\r\n get #activeTimeMillisSinceLastStart() {\r\n if (this.#startedUnixEpochMillis === null)\r\n return 0;\r\n\r\n return (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\r\n }\r\n\r\n get #totalTime() {\r\n if (this.#firstStartedUnixEpochMillis === null)\r\n return 0;\r\n\r\n return this.#nowUnixEpochMillis - this.#firstStartedUnixEpochMillis;\r\n }\r\n\r\n get #remainingBytes() {\r\n return this.#totalSize - this.#downloadedBytes;\r\n }\r\n\r\n get #isItTimeForGlobalProgressEvent(): boolean {\r\n return this.#lastProgressTickUnixEpochMillis === null || (this.#nowUnixEpochMillis - this.#lastProgressTickUnixEpochMillis) > this.#options.progressTickMillis;\r\n }\r\n\r\n start(): boolean {\r\n if (this.#status === TransferStatus.Initialized) { // can start only once!\r\n this.#status = TransferStatus.Running;\r\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\r\n this.#firstStartedUnixEpochMillis = this.#startedUnixEpochMillis;\r\n const args: DownloadEventArgs = this.#buildDownloadEventArgs(true);\r\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadStarted, args);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n requestPause(options: { interruptPendingChunks: boolean, pausedTrigger?: (paused: boolean) => void }): void {\r\n this.#pausedTrigger = undefined;\r\n\r\n if (this.#status === TransferStatus.Running) {\r\n this.#status = TransferStatus.Pausing;\r\n this.#pauseImmediately = options.interruptPendingChunks;\r\n this.#pausedTrigger = options.pausedTrigger;\r\n const pauseArgs: DownloadPauseEventArgs = this.#buildPauseDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.Pausing, pauseArgs);\r\n }\r\n else if (options.pausedTrigger)\r\n options.pausedTrigger(false);\r\n }\r\n\r\n paused(): Promise<TransferStatus | null> {\r\n if (this.#status === TransferStatus.Pausing) {\r\n this.#status = TransferStatus.Paused;\r\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\r\n const pauseArgs: DownloadPauseEventArgs = this.#buildPauseDownloadEventArgs();\r\n this.#startedUnixEpochMillis = null;\r\n this.#lastSpeedCalc = null;\r\n this.#currentSpeedMeasurementDownloadedBytes = [];\r\n this.#estimatedRemainingTimeSeconds = null;\r\n this.#pauseImmediately = false;\r\n this.#eventsEngine.emit(TransferDownloadEvent.Paused, pauseArgs);\r\n\r\n if (this.#pausedTrigger) {\r\n this.#pausedTrigger(true);\r\n this.#pausedTrigger = undefined;\r\n }\r\n\r\n return new Promise(resolve => {\r\n this.#resumeResolve = resolve;\r\n });\r\n }\r\n return Promise.resolve(null);\r\n }\r\n\r\n resume(): boolean {\r\n if (this.#status === TransferStatus.Pausing) {\r\n this.#status = TransferStatus.Running;\r\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.Resumed, args);\r\n return true;\r\n }\r\n if (this.#status === TransferStatus.Paused) {\r\n this.#status = TransferStatus.Running;\r\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\r\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.Resumed, args);\r\n if (this.#resumeResolve) {\r\n this.#resumeResolve(TransferStatus.Running);\r\n this.#resumeResolve = undefined;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n requestAbort(): boolean {\r\n if (this.#status === TransferStatus.Running || this.#status === TransferStatus.Pausing || this.#status === TransferStatus.Paused) {\r\n this.#status = TransferStatus.Aborting;\r\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.Aborting, args);\r\n if (this.#resumeResolve) {\r\n this.#resumeResolve(TransferStatus.Aborting);\r\n this.#resumeResolve = undefined;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n aborted(): boolean {\r\n if (this.#status === TransferStatus.Aborting) {\r\n this.#status = TransferStatus.Aborted;\r\n if (this.#startedUnixEpochMillis !== null)\r\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\r\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.Aborted, args);\r\n\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n fileStarting(file: DownloadFileInfo) {\r\n file.starting();\r\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadStarting, args);\r\n }\r\n\r\n fileCreating(file: DownloadFileInfo) {\r\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileCreating, args);\r\n }\r\n\r\n fileCreated(file: DownloadFileInfo) {\r\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileCreated, args);\r\n }\r\n\r\n fileFailedById(fileId: string, reason: DownloadError) {\r\n const actualFile = (this.#files.find(x => x.externalId === fileId))!;\r\n this.fileFailed(actualFile, reason);\r\n }\r\n\r\n fileFailed(file: DownloadFileInfo, reason: DownloadError): void {\r\n if (file.isFailed === false) {\r\n file.fail(reason);\r\n const args: FileDownloadFailedEventArgs = {\r\n ...this.#buildFileDownloadEventArgs(file),\r\n reason,\r\n };\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadFailed, args);\r\n }\r\n\r\n this.#failedFiles.add(file);\r\n this.#pendingFiles.delete(file);\r\n }\r\n\r\n fileCompleted(fileId: string, finalDownloadPath: string): void {\r\n const actualFile = (this.#files.find(x => x.externalId === fileId))!;\r\n actualFile.complete(finalDownloadPath);\r\n const updatedArgs = this.#buildFileDownloadEventArgs(actualFile);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadCompleted, updatedArgs);\r\n }\r\n\r\n fileCompleting(file: DownloadFileInfo): void {\r\n const removed = this.#pendingFiles.delete(file);\r\n if (removed || file.sizeInBytes === 0) {\r\n this.#downloadedBytes_bank += file.sizeInBytes;\r\n const fileArgs = this.#buildFileDownloadEventArgs(file!);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadProgressed, fileArgs);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadCompleting, fileArgs);\r\n }\r\n }\r\n\r\n chunkDownloadStarted(file: DownloadFileInfo, chunk: DownloadFileChunkInfo): void {\r\n file.chunkStarted(chunk);\r\n const args: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\r\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadStarted, args);\r\n }\r\n\r\n chunkDownloadProgressed(file: DownloadFileInfo, chunk: DownloadFileChunkInfo, progress: ChunkProgressEvent): void {\r\n if (!file.isStarted)\r\n this.#fileStarted(file);\r\n\r\n this.networkOk();\r\n\r\n chunk.setProgress(progress.transferredBytesTotal);\r\n const chunkArgs: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\r\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadProgressed, chunkArgs);\r\n\r\n if (this.#isItTimeForFileProgressEvent(file))\r\n this.#fileProgressed(file);\r\n\r\n if (this.#isItTimeForGlobalProgressEvent)\r\n this.#progressed();\r\n }\r\n\r\n chunkDownloadCompleted(file: DownloadFileInfo, chunk: DownloadFileChunkInfo): void {\r\n chunk.complete();\r\n file.chunkCompleted(chunk);\r\n file.updateProgress();\r\n\r\n const chunkArgs: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\r\n\r\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadProgressed, chunkArgs);\r\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadCompleted, chunkArgs);\r\n\r\n this.#tryCompleteFile(file);\r\n }\r\n\r\n chunkDownloadFailed(file: DownloadFileInfo, chunk: DownloadFileChunkInfo, reason: DownloadError): void {\r\n chunk.fail(reason);\r\n file.chunkFailed(chunk);\r\n\r\n const args: ChunkDownloadFailedEventArgs = {\r\n ...this.#buildChunkDownloadEventArgs(file, chunk),\r\n reason,\r\n };\r\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadFailed, args);\r\n\r\n // we've tried multiple times - but chunk still cannot be downloaded - fail this file\r\n this.fileFailed(file, reason);\r\n }\r\n\r\n completed(error?: Error): void {\r\n if (this.#status === TransferStatus.Completed || this.#status === TransferStatus.Failed)\r\n throw new DownloadError(`Download ${this.#downloadId} completion cannot be triggered in state ${TransferStatus[this.#status]}`);\r\n\r\n const failedFiles = this.#mapFailedFiles();\r\n\r\n if (!!error || failedFiles.length)\r\n this.#status = TransferStatus.Failed;\r\n else\r\n this.#status = TransferStatus.Completed;\r\n\r\n this.#progressed();\r\n\r\n const args: DownloadCompletedEventArgs = {\r\n ...this.#buildDownloadEventArgs(true),\r\n failedFiles,\r\n downloadError: error,\r\n };\r\n\r\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadCompleted, args);\r\n }\r\n\r\n registeringTransferDownload(): void {\r\n if (this.#status !== TransferStatus.Completed) {\r\n const args: DownloadEventArgs = { ...this.#buildDownloadEventArgs() };\r\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadRegistrationTriggered, args);\r\n }\r\n }\r\n\r\n registeringFileDownload(): void {\r\n if (this.#status !== TransferStatus.Completed) {\r\n const args: DownloadEventArgs = { ...this.#buildDownloadEventArgs() };\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadRegistrationTriggered, args);\r\n }\r\n }\r\n\r\n getCurrentState(withFiles: boolean): DownloadEventArgs {\r\n return this.#buildDownloadEventArgs(withFiles);\r\n }\r\n\r\n networkFailure() {\r\n this.#consecutiveNetworkErrors += 1;\r\n if (this.#options.fileserverOfflineAfterConsecutiveAttempts > -1\r\n && this.#consecutiveNetworkErrors > this.#options.fileserverOfflineAfterConsecutiveAttempts\r\n && this.#networkStatus === true) {\r\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\r\n this.#startedUnixEpochMillis = null;\r\n this.#lastSpeedCalc = null;\r\n this.#currentSpeedMeasurementDownloadedBytes = [];\r\n this.#estimatedRemainingTimeSeconds = null;\r\n this.#networkStatus = false;\r\n this.#eventsEngine.emit(TransferDownloadEvent.NetworkFailure);\r\n }\r\n }\r\n\r\n networkOk() {\r\n this.#consecutiveNetworkErrors = 0;\r\n if (this.#networkStatus === false) {\r\n this.#networkStatus = true;\r\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\r\n this.#eventsEngine.emit(TransferDownloadEvent.NetworkOk);\r\n }\r\n }\r\n\r\n possibleSupersizedFile(file: DownloadFileInfo) {\r\n // sometimes when FS returns too many bytes the file size could get bigger on disk than it was initially created with\r\n // truncate the file in this case\r\n const fileArgs: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\r\n this.#eventsEngine.emit(TransferDownloadEvent.PossibleSupersizedFile, fileArgs);\r\n }\r\n\r\n #progressed(): void {\r\n this.#updateProgress();\r\n\r\n const globalArgs: DownloadEventArgs = this.#buildDownloadEventArgs();\r\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadProgressed, globalArgs);\r\n }\r\n\r\n #fileProgressed(file: DownloadFileInfo): void {\r\n file.updateProgress();\r\n\r\n const fileArgs: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadProgressed, fileArgs);\r\n }\r\n\r\n #fileStarted(file: DownloadFileInfo): void {\r\n file.start();\r\n\r\n this.#pendingFiles.add(file);\r\n\r\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\r\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadStarted, args);\r\n }\r\n\r\n #tryCompleteFile(file: DownloadFileInfo): void {\r\n if (file.chunks.every(chunk => chunk.isCompleted))\r\n this.fileCompleting(file);\r\n }\r\n\r\n #isItTimeForFileProgressEvent(file: DownloadFileInfo): boolean {\r\n return file.lastProgressTick === null || (this.#nowUnixEpochMillis - file.lastProgressTick) > this.#options.progressTickMillis;\r\n }\r\n\r\n #buildFileDownloadEventArgs(file: DownloadFileInfo): FileDownloadEventArgs {\r\n return {\r\n transferId: this.#transferId,\r\n file: this.#mapFileProgress(file),\r\n activeTime: this.#activeTimeMillis,\r\n };\r\n }\r\n\r\n #buildChunkDownloadEventArgs(file: DownloadFileInfo, chunk: DownloadFileChunkInfo) {\r\n return {\r\n ...this.#buildFileDownloadEventArgs(file),\r\n chunk: this.#mapChunkProgress(chunk),\r\n };\r\n }\r\n\r\n #buildDownloadEventArgs(withFiles = false): DownloadEventArgs {\r\n return {\r\n status: this.#status,\r\n downloadId: this.#downloadId,\r\n transferId: this.#transferId,\r\n activeTimeMillis: this.#activeTimeMillis,\r\n totalTimeMillis: this.#totalTime,\r\n progressPercent: this.#percent,\r\n bytesPerSecondAverage: this.#bytesPerSecondAverage,\r\n bytesPerSecondCurrent: this.#bytesPerSecondCurrent,\r\n estimatedRemainingTimeSeconds: this.#estimatedRemainingTimeSeconds,\r\n totalSize: this.#totalSize,\r\n downloadedBytes: this.#downloadedBytes,\r\n files: withFiles ? this.#mapFilesProgress() : null,\r\n downloadBaseFolder: this.#options.downloadFolder!,\r\n };\r\n }\r\n\r\n notifyMetadataDetermined(fileServerUrl: string, region?: string) {\r\n const eventArgs: DownloadMetadataDeterminedEventArgs = { ...this.#buildDownloadEventArgs(), region, fileServerUrl };\r\n this.#eventsEngine.emit(TransferDownloadEvent.TransferMetadataDetermined, eventArgs);\r\n }\r\n\r\n #buildPauseDownloadEventArgs(): DownloadPauseEventArgs {\r\n return { ...this.#buildDownloadEventArgs(), interruptPendingChunks: this.#pauseImmediately };\r\n }\r\n\r\n #updateProgress(): void {\r\n const now = this.#nowUnixEpochMillis;\r\n this.#lastProgressTickUnixEpochMillis = now;\r\n\r\n this.#downloadedBytes = this.#downloadedBytes_bank;\r\n for (const file of this.#pendingFiles)\r\n this.#downloadedBytes += file.downloadedBytes;\r\n\r\n this.#currentSpeedMeasurementDownloadedBytes.push({ time: now, bytes: this.#downloadedBytes });\r\n\r\n if (this.#totalSize === 0)\r\n this.#percent = 100;\r\n else\r\n this.#percent = Math.min(100, (100 * this.#downloadedBytes) / this.#totalSize);\r\n\r\n // all-time bytes/sec\r\n const activeTime = this.#activeTimeMillis;\r\n if (activeTime > 0)\r\n this.#bytesPerSecondAverage = this.#downloadedBytes / (activeTime / 1000);\r\n\r\n const shouldWeCalculateSpeed = (this.#lastSpeedCalc === null && this.#activeTimeMillisSinceLastStart > 1500)\r\n || (this.#lastSpeedCalc !== null && (now - this.#lastSpeedCalc) > 200);\r\n\r\n if (shouldWeCalculateSpeed) {\r\n this.#lastSpeedCalc = now;\r\n\r\n // momentary bytes/sec\r\n const prev = this.#currentSpeedMeasurementDownloadedBytes[0]!;\r\n const timeDiff = now - prev.time;\r\n this.#bytesPerSecondCurrent = Math.max(0, this.#downloadedBytes - prev.bytes) / (timeDiff / 1000);\r\n if (timeDiff > this.#options.momentaryDownloadSpeedTimespanMillis)\r\n this.#currentSpeedMeasurementDownloadedBytes.shift();\r\n\r\n // remaining time (seconds) - based on momentary speed and remaining bytes to download - and smoothing factor\r\n if (this.#remainingBytes === 0)\r\n this.#estimatedRemainingTimeSeconds = 0;\r\n else if (this.#bytesPerSecondCurrent > 0) {\r\n const newRemaining = this.#remainingBytes / this.#bytesPerSecondCurrent;\r\n if (this.#estimatedRemainingTimeSeconds)\r\n this.#estimatedRemainingTimeSeconds = (0.7 * newRemaining) + (0.3 * this.#estimatedRemainingTimeSeconds);\r\n else\r\n this.#estimatedRemainingTimeSeconds = newRemaining;\r\n }\r\n }\r\n }\r\n\r\n #mapFilesProgress(): Array<DownloadFileProgress> {\r\n return this.#files.map(x => this.#mapFileProgress(x));\r\n }\r\n\r\n #mapFailedFiles(): Array<DownloadFileProgress> {\r\n const result: Array<DownloadFileProgress> = [];\r\n for (const x of this.#failedFiles)\r\n result.push(this.#mapFileProgress(x));\r\n return result;\r\n }\r\n\r\n #mapFileProgress(file: DownloadFileInfo): DownloadFileProgress {\r\n return DownloadFileProgress.FromFileDownloadInfo(file);\r\n }\r\n\r\n #mapChunkProgress(chunk: DownloadFileChunkInfo): DownloadFileChunkProgress {\r\n return DownloadFileChunkProgress.FromChunkInfo(chunk);\r\n }\r\n}"]}
1
+ {"version":3,"file":"downloadState.js","sourceRoot":"","sources":["../../../../src/downloader/downloadStatus/downloadState.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AAiBvE,MAAM,CAAC,OAAO,OAAO,aAAa;IACrB,WAAW,CAAS;IACpB,WAAW,CAAS;IACpB,QAAQ,CAAkB;IAC1B,aAAa,CAAe;IAE5B,MAAM,CAA0B;IAChC,YAAY,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAClE,aAAa,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAE5E,UAAU,GAAG,CAAC,CAAC;IACf,cAAc,GAAG,IAAI,CAAC;IACtB,yBAAyB,GAAG,CAAC,CAAC;IAC9B,OAAO,GAAmB,cAAc,CAAC,WAAW,CAAC;IACrD,4BAA4B,GAAkB,IAAI,CAAC;IACnD,uBAAuB,GAAkB,IAAI,CAAC;IAC9C,oBAAoB,GAAG,CAAC,CAAC;IACzB,gCAAgC,GAAkB,IAAI,CAAC;IACvD,cAAc,GAAkB,IAAI,CAAC;IACrC,QAAQ,GAAG,CAAC,CAAC;IAEb;;OAEG;IACH,qBAAqB,GAAG,CAAC,CAAC;IAC1B;;OAEG;IACH,gBAAgB,GAAG,CAAC,CAAC;IAErB,sBAAsB,GAAG,CAAC,CAAC;IAC3B,sBAAsB,GAAG,CAAC,CAAC;IAC3B,uCAAuC,GAA2C,EAAE,CAAC;IACrF,8BAA8B,GAAkB,IAAI,CAAC;IACrD,iBAAiB,GAAG,KAAK,CAAC;IAC1B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AAC,8BAA8B;oBACnC,IAAI,CAAC,8BAA8B,GAAG,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,8BAA8B,CAAC,CAAC;;oBAEzG,IAAI,CAAC,8BAA8B,GAAG,YAAY,CAAC;YAC3D,CAAC;QACL,CAAC;IACL,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,eAAe;QACX,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,YAAY;YAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,gBAAgB,CAAC,IAAsB;QACnC,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,iBAAiB,CAAC,KAA4B;QAC1C,OAAO,yBAAyB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;CACJ","sourcesContent":["import TransferStatus from \"../../utils/types/transferStatus.js\";\nimport TransferDownloadEvent from \"../dtos/downloadEvent.js\";\nimport DownloadError from \"../dtos/downloadError.js\";\nimport DownloadFileProgress from \"./downloadFileProgress.js\";\nimport DownloadFileChunkProgress from \"./downloadFileChunkProgress.js\";\n\nimport type DownloadFileInfo from \"../dtos/downloadFileInfo.js\";\nimport type DownloadFileChunkInfo from \"../dtos/downloadFileChunkInfo.js\";\nimport type EventsEngine from \"../../utils/events/eventsEngine.js\";\nimport type DownloadEventArgs from \"../eventArgs/downloadEventArgs.js\";\nimport type DownloadCompletedEventArgs from \"../eventArgs/downloadCompletedEventArgs.js\";\nimport type DownloadPauseEventArgs from \"../eventArgs/downloadPauseEventArgs.js\";\nimport type FileDownloadEventArgs from \"../eventArgs/fileDownloadEventArgs.js\";\nimport type FileDownloadFailedEventArgs from \"../eventArgs/fileDownloadFailedEventArgs.js\";\nimport type ChunkDownloadEventArgs from \"../eventArgs/chunkDownloadEventArgs.js\";\nimport type ChunkDownloadFailedEventArgs from \"../eventArgs/chunkDownloadFailedEventArgs.js\";\nimport type ChunkProgressEvent from \"../../utils/events/chunkProgressEvent.js\";\nimport type DownloaderRestoredState from \"../dtos/downloaderRestoredState.js\";\nimport type DownloadOptions from \"../downloadOptions.js\";\nimport type DownloadMetadataDeterminedEventArgs from \"../eventArgs/downloadMetadataDeterminedEventArgs.js\";\n\nexport default class DownloadState {\n readonly #transferId: string;\n readonly #downloadId: string;\n readonly #options: DownloadOptions;\n readonly #eventsEngine: EventsEngine;\n\n readonly #files: Array<DownloadFileInfo>;\n readonly #failedFiles: Set<DownloadFileInfo> = new Set<DownloadFileInfo>();\n readonly #pendingFiles: Set<DownloadFileInfo> = new Set<DownloadFileInfo>();\n\n #totalSize = 0;\n #networkStatus = true;\n #consecutiveNetworkErrors = 0;\n #status: TransferStatus = TransferStatus.Initialized;\n #firstStartedUnixEpochMillis: number | null = null;\n #startedUnixEpochMillis: number | null = null;\n #elapsedActiveMillis = 0;\n #lastProgressTickUnixEpochMillis: number | null = null;\n #lastSpeedCalc: number | null = null;\n #percent = 0;\n\n /**\n * How many bytes downloaded - counting only completed files.\n */\n #downloadedBytes_bank = 0;\n /**\n * How many bytes downloaded total (bank + pendingFiles).\n */\n #downloadedBytes = 0;\n\n #bytesPerSecondAverage = 0;\n #bytesPerSecondCurrent = 0;\n #currentSpeedMeasurementDownloadedBytes: Array<{ time: number, bytes: number }> = [];\n #estimatedRemainingTimeSeconds: number | null = null;\n #pauseImmediately = false;\n #pausedTrigger?: (pauseTriggered: boolean) => void;\n #resumeResolve?: (status: TransferStatus) => void;\n\n constructor(downloadId: string, transferId: string, files: Array<DownloadFileInfo>, options: DownloadOptions, eventsEngine: EventsEngine, oldState?: DownloaderRestoredState) {\n this.#downloadId = downloadId;\n this.#transferId = transferId;\n this.#eventsEngine = eventsEngine;\n this.#files = files;\n this.#options = options;\n\n if (oldState) {\n this.#elapsedActiveMillis = oldState.activeTime;\n this.#downloadedBytes = oldState.downloadedBytes;\n this.#downloadedBytes_bank = oldState.downloadedBytesBank;\n this.#totalSize = oldState.totalSize;\n this.#percent = oldState.percent;\n }\n else {\n for (const file of this.#files)\n this.#totalSize += file.sizeInBytes;\n }\n }\n\n get isRunning(): boolean {\n return this.#status === TransferStatus.Running;\n }\n\n get status(): TransferStatus {\n return this.#status;\n }\n\n get hasFailedFiles(): boolean {\n return this.#failedFiles.size > 0;\n }\n\n get allFilesCompletedOrFailed(): boolean {\n return this.#files.every(x => x.isCompleted || x.isFailed);\n }\n\n get averageBytesPerSecond(): number {\n return this.#bytesPerSecondAverage;\n }\n\n get isThereNetworkProblem(): boolean {\n return this.#networkStatus === false;\n }\n\n get pauseImmediately(): boolean {\n return this.#pauseImmediately;\n }\n\n get currentState(): DownloadEventArgs {\n return this.#buildDownloadEventArgs();\n }\n\n get #nowUnixEpochMillis() {\n return new Date().getTime();\n }\n\n get #activeTimeMillis() {\n return this.#elapsedActiveMillis + this.#activeTimeMillisSinceLastStart;\n }\n\n get #activeTimeMillisSinceLastStart() {\n if (this.#startedUnixEpochMillis === null)\n return 0;\n\n return (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\n }\n\n get #totalTime() {\n if (this.#firstStartedUnixEpochMillis === null)\n return 0;\n\n return this.#nowUnixEpochMillis - this.#firstStartedUnixEpochMillis;\n }\n\n get #remainingBytes() {\n return this.#totalSize - this.#downloadedBytes;\n }\n\n get #isItTimeForGlobalProgressEvent(): boolean {\n return this.#lastProgressTickUnixEpochMillis === null || (this.#nowUnixEpochMillis - this.#lastProgressTickUnixEpochMillis) > this.#options.progressTickMillis;\n }\n\n start(): boolean {\n if (this.#status === TransferStatus.Initialized) { // can start only once!\n this.#status = TransferStatus.Running;\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\n this.#firstStartedUnixEpochMillis = this.#startedUnixEpochMillis;\n const args: DownloadEventArgs = this.#buildDownloadEventArgs(true);\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadStarted, args);\n return true;\n }\n return false;\n }\n\n requestPause(options: { interruptPendingChunks: boolean, pausedTrigger?: (paused: boolean) => void }): void {\n this.#pausedTrigger = undefined;\n\n if (this.#status === TransferStatus.Running) {\n this.#status = TransferStatus.Pausing;\n this.#pauseImmediately = options.interruptPendingChunks;\n this.#pausedTrigger = options.pausedTrigger;\n const pauseArgs: DownloadPauseEventArgs = this.#buildPauseDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.Pausing, pauseArgs);\n }\n else if (options.pausedTrigger)\n options.pausedTrigger(false);\n }\n\n paused(): Promise<TransferStatus | null> {\n if (this.#status === TransferStatus.Pausing) {\n this.#status = TransferStatus.Paused;\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\n const pauseArgs: DownloadPauseEventArgs = this.#buildPauseDownloadEventArgs();\n this.#startedUnixEpochMillis = null;\n this.#lastSpeedCalc = null;\n this.#currentSpeedMeasurementDownloadedBytes = [];\n this.#estimatedRemainingTimeSeconds = null;\n this.#pauseImmediately = false;\n this.#eventsEngine.emit(TransferDownloadEvent.Paused, pauseArgs);\n\n if (this.#pausedTrigger) {\n this.#pausedTrigger(true);\n this.#pausedTrigger = undefined;\n }\n\n return new Promise(resolve => {\n this.#resumeResolve = resolve;\n });\n }\n return Promise.resolve(null);\n }\n\n resume(): boolean {\n if (this.#status === TransferStatus.Pausing) {\n this.#status = TransferStatus.Running;\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.Resumed, args);\n return true;\n }\n if (this.#status === TransferStatus.Paused) {\n this.#status = TransferStatus.Running;\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.Resumed, args);\n if (this.#resumeResolve) {\n this.#resumeResolve(TransferStatus.Running);\n this.#resumeResolve = undefined;\n }\n return true;\n }\n return false;\n }\n\n requestAbort(): boolean {\n if (this.#status === TransferStatus.Running || this.#status === TransferStatus.Pausing || this.#status === TransferStatus.Paused) {\n this.#status = TransferStatus.Aborting;\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.Aborting, args);\n if (this.#resumeResolve) {\n this.#resumeResolve(TransferStatus.Aborting);\n this.#resumeResolve = undefined;\n }\n return true;\n }\n return false;\n }\n\n aborted(): boolean {\n if (this.#status === TransferStatus.Aborting) {\n this.#status = TransferStatus.Aborted;\n if (this.#startedUnixEpochMillis !== null)\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\n const args: DownloadEventArgs = this.#buildDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.Aborted, args);\n\n return true;\n }\n return false;\n }\n\n fileStarting(file: DownloadFileInfo) {\n file.starting();\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadStarting, args);\n }\n\n fileCreating(file: DownloadFileInfo) {\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\n this.#eventsEngine.emit(TransferDownloadEvent.FileCreating, args);\n }\n\n ensureFileStarted(file: DownloadFileInfo): void {\n if (!file.isStarted)\n this.#fileStarted(file);\n }\n\n fileCreated(file: DownloadFileInfo) {\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file!);\n this.#eventsEngine.emit(TransferDownloadEvent.FileCreated, args);\n }\n\n fileFailedById(fileId: string, reason: DownloadError) {\n const actualFile = (this.#files.find(x => x.externalId === fileId))!;\n this.fileFailed(actualFile, reason);\n }\n\n fileFailed(file: DownloadFileInfo, reason: DownloadError): void {\n if (file.isFailed === false) {\n file.fail(reason);\n const args: FileDownloadFailedEventArgs = {\n ...this.#buildFileDownloadEventArgs(file),\n reason,\n };\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadFailed, args);\n }\n\n this.#failedFiles.add(file);\n this.#pendingFiles.delete(file);\n }\n\n fileCompleted(fileId: string, finalDownloadPath: string): void {\n const actualFile = (this.#files.find(x => x.externalId === fileId))!;\n actualFile.complete(finalDownloadPath);\n const updatedArgs = this.#buildFileDownloadEventArgs(actualFile);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadCompleted, updatedArgs);\n }\n\n fileCompleting(file: DownloadFileInfo): void {\n const removed = this.#pendingFiles.delete(file);\n if (removed || file.sizeInBytes === 0) {\n this.#downloadedBytes_bank += file.sizeInBytes;\n const fileArgs = this.#buildFileDownloadEventArgs(file!);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadProgressed, fileArgs);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadCompleting, fileArgs);\n }\n }\n\n chunkDownloadStarted(file: DownloadFileInfo, chunk: DownloadFileChunkInfo): void {\n file.chunkStarted(chunk);\n const args: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadStarted, args);\n }\n\n chunkDownloadProgressed(file: DownloadFileInfo, chunk: DownloadFileChunkInfo, progress: ChunkProgressEvent): void {\n if (!file.isStarted)\n this.#fileStarted(file);\n\n this.networkOk();\n\n chunk.setProgress(progress.transferredBytesTotal);\n const chunkArgs: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadProgressed, chunkArgs);\n\n if (this.#isItTimeForFileProgressEvent(file))\n this.#fileProgressed(file);\n\n if (this.#isItTimeForGlobalProgressEvent)\n this.#progressed();\n }\n\n chunkDownloadCompleted(file: DownloadFileInfo, chunk: DownloadFileChunkInfo): void {\n chunk.complete();\n file.chunkCompleted(chunk);\n file.updateProgress();\n\n const chunkArgs: ChunkDownloadEventArgs = this.#buildChunkDownloadEventArgs(file, chunk);\n\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadProgressed, chunkArgs);\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadCompleted, chunkArgs);\n\n this.#tryCompleteFile(file);\n }\n\n chunkDownloadFailed(file: DownloadFileInfo, chunk: DownloadFileChunkInfo, reason: DownloadError): void {\n chunk.fail(reason);\n file.chunkFailed(chunk);\n\n const args: ChunkDownloadFailedEventArgs = {\n ...this.#buildChunkDownloadEventArgs(file, chunk),\n reason,\n };\n this.#eventsEngine.emit(TransferDownloadEvent.ChunkDownloadFailed, args);\n\n // we've tried multiple times - but chunk still cannot be downloaded - fail this file\n this.fileFailed(file, reason);\n }\n\n completed(error?: Error): void {\n if (this.#status === TransferStatus.Completed || this.#status === TransferStatus.Failed)\n throw new DownloadError(`Download ${this.#downloadId} completion cannot be triggered in state ${TransferStatus[this.#status]}`);\n\n const failedFiles = this.#mapFailedFiles();\n\n if (!!error || failedFiles.length)\n this.#status = TransferStatus.Failed;\n else\n this.#status = TransferStatus.Completed;\n\n this.#progressed();\n\n const args: DownloadCompletedEventArgs = {\n ...this.#buildDownloadEventArgs(true),\n failedFiles,\n downloadError: error,\n };\n\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadCompleted, args);\n }\n\n registeringTransferDownload(): void {\n if (this.#status !== TransferStatus.Completed) {\n const args: DownloadEventArgs = { ...this.#buildDownloadEventArgs() };\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadRegistrationTriggered, args);\n }\n }\n\n registeringFileDownload(): void {\n if (this.#status !== TransferStatus.Completed) {\n const args: DownloadEventArgs = { ...this.#buildDownloadEventArgs() };\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadRegistrationTriggered, args);\n }\n }\n\n getCurrentState(withFiles: boolean): DownloadEventArgs {\n return this.#buildDownloadEventArgs(withFiles);\n }\n\n networkFailure() {\n this.#consecutiveNetworkErrors += 1;\n if (this.#options.fileserverOfflineAfterConsecutiveAttempts > -1\n && this.#consecutiveNetworkErrors > this.#options.fileserverOfflineAfterConsecutiveAttempts\n && this.#networkStatus === true) {\n this.#elapsedActiveMillis += (this.#nowUnixEpochMillis - this.#startedUnixEpochMillis!);\n this.#startedUnixEpochMillis = null;\n this.#lastSpeedCalc = null;\n this.#currentSpeedMeasurementDownloadedBytes = [];\n this.#estimatedRemainingTimeSeconds = null;\n this.#networkStatus = false;\n this.#eventsEngine.emit(TransferDownloadEvent.NetworkFailure);\n }\n }\n\n networkOk() {\n this.#consecutiveNetworkErrors = 0;\n if (this.#networkStatus === false) {\n this.#networkStatus = true;\n this.#startedUnixEpochMillis = this.#nowUnixEpochMillis;\n this.#eventsEngine.emit(TransferDownloadEvent.NetworkOk);\n }\n }\n\n possibleSupersizedFile(file: DownloadFileInfo) {\n // sometimes when FS returns too many bytes the file size could get bigger on disk than it was initially created with\n // truncate the file in this case\n const fileArgs: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\n this.#eventsEngine.emit(TransferDownloadEvent.PossibleSupersizedFile, fileArgs);\n }\n\n #progressed(): void {\n this.#updateProgress();\n\n const globalArgs: DownloadEventArgs = this.#buildDownloadEventArgs();\n this.#eventsEngine.emit(TransferDownloadEvent.DownloadProgressed, globalArgs);\n }\n\n #fileProgressed(file: DownloadFileInfo): void {\n file.updateProgress();\n\n const fileArgs: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadProgressed, fileArgs);\n }\n\n #fileStarted(file: DownloadFileInfo): void {\n file.start();\n\n this.#pendingFiles.add(file);\n\n const args: FileDownloadEventArgs = this.#buildFileDownloadEventArgs(file);\n this.#eventsEngine.emit(TransferDownloadEvent.FileDownloadStarted, args);\n }\n\n #tryCompleteFile(file: DownloadFileInfo): void {\n if (file.chunks.every(chunk => chunk.isCompleted))\n this.fileCompleting(file);\n }\n\n #isItTimeForFileProgressEvent(file: DownloadFileInfo): boolean {\n return file.lastProgressTick === null || (this.#nowUnixEpochMillis - file.lastProgressTick) > this.#options.progressTickMillis;\n }\n\n #buildFileDownloadEventArgs(file: DownloadFileInfo): FileDownloadEventArgs {\n return {\n transferId: this.#transferId,\n file: this.#mapFileProgress(file),\n activeTime: this.#activeTimeMillis,\n };\n }\n\n #buildChunkDownloadEventArgs(file: DownloadFileInfo, chunk: DownloadFileChunkInfo) {\n return {\n ...this.#buildFileDownloadEventArgs(file),\n chunk: this.#mapChunkProgress(chunk),\n };\n }\n\n #buildDownloadEventArgs(withFiles = false): DownloadEventArgs {\n return {\n status: this.#status,\n downloadId: this.#downloadId,\n transferId: this.#transferId,\n activeTimeMillis: this.#activeTimeMillis,\n totalTimeMillis: this.#totalTime,\n progressPercent: this.#percent,\n bytesPerSecondAverage: this.#bytesPerSecondAverage,\n bytesPerSecondCurrent: this.#bytesPerSecondCurrent,\n estimatedRemainingTimeSeconds: this.#estimatedRemainingTimeSeconds,\n totalSize: this.#totalSize,\n downloadedBytes: this.#downloadedBytes,\n files: withFiles ? this.#mapFilesProgress() : null,\n downloadBaseFolder: this.#options.downloadFolder!,\n };\n }\n\n notifyMetadataDetermined(fileServerUrl: string, region?: string) {\n const eventArgs: DownloadMetadataDeterminedEventArgs = { ...this.#buildDownloadEventArgs(), region, fileServerUrl };\n this.#eventsEngine.emit(TransferDownloadEvent.TransferMetadataDetermined, eventArgs);\n }\n\n #buildPauseDownloadEventArgs(): DownloadPauseEventArgs {\n return { ...this.#buildDownloadEventArgs(), interruptPendingChunks: this.#pauseImmediately };\n }\n\n #updateProgress(): void {\n const now = this.#nowUnixEpochMillis;\n this.#lastProgressTickUnixEpochMillis = now;\n\n this.#downloadedBytes = this.#downloadedBytes_bank;\n for (const file of this.#pendingFiles)\n this.#downloadedBytes += file.downloadedBytes;\n\n this.#currentSpeedMeasurementDownloadedBytes.push({ time: now, bytes: this.#downloadedBytes });\n\n if (this.#totalSize === 0)\n this.#percent = 100;\n else\n this.#percent = Math.min(100, (100 * this.#downloadedBytes) / this.#totalSize);\n\n // all-time bytes/sec\n const activeTime = this.#activeTimeMillis;\n if (activeTime > 0)\n this.#bytesPerSecondAverage = this.#downloadedBytes / (activeTime / 1000);\n\n const shouldWeCalculateSpeed = (this.#lastSpeedCalc === null && this.#activeTimeMillisSinceLastStart > 1500)\n || (this.#lastSpeedCalc !== null && (now - this.#lastSpeedCalc) > 200);\n\n if (shouldWeCalculateSpeed) {\n this.#lastSpeedCalc = now;\n\n // momentary bytes/sec\n const prev = this.#currentSpeedMeasurementDownloadedBytes[0]!;\n const timeDiff = now - prev.time;\n this.#bytesPerSecondCurrent = Math.max(0, this.#downloadedBytes - prev.bytes) / (timeDiff / 1000);\n if (timeDiff > this.#options.momentaryDownloadSpeedTimespanMillis)\n this.#currentSpeedMeasurementDownloadedBytes.shift();\n\n // remaining time (seconds) - based on momentary speed and remaining bytes to download - and smoothing factor\n if (this.#remainingBytes === 0)\n this.#estimatedRemainingTimeSeconds = 0;\n else if (this.#bytesPerSecondCurrent > 0) {\n const newRemaining = this.#remainingBytes / this.#bytesPerSecondCurrent;\n if (this.#estimatedRemainingTimeSeconds)\n this.#estimatedRemainingTimeSeconds = (0.7 * newRemaining) + (0.3 * this.#estimatedRemainingTimeSeconds);\n else\n this.#estimatedRemainingTimeSeconds = newRemaining;\n }\n }\n }\n\n #mapFilesProgress(): Array<DownloadFileProgress> {\n return this.#files.map(x => this.#mapFileProgress(x));\n }\n\n #mapFailedFiles(): Array<DownloadFileProgress> {\n const result: Array<DownloadFileProgress> = [];\n for (const x of this.#failedFiles)\n result.push(this.#mapFileProgress(x));\n return result;\n }\n\n #mapFileProgress(file: DownloadFileInfo): DownloadFileProgress {\n return DownloadFileProgress.FromFileDownloadInfo(file);\n }\n\n #mapChunkProgress(chunk: DownloadFileChunkInfo): DownloadFileChunkProgress {\n return DownloadFileChunkProgress.FromChunkInfo(chunk);\n }\n}\n"]}
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 @@ class DownloadTracker {
109
109
  pendingFile.c = args.file.completed;
110
110
  pendingFile.er = args.file.failed;
111
111
  pendingFile.ok = args.file.lastOkChunk;
112
+ pendingFile.ec = null;
112
113
  this.#progress.activeTime = args.activeTime;
113
114
  this.#progressChanged = true;
114
115
  const file = this.#allFiles[args.file.id];
@@ -122,6 +123,7 @@ class DownloadTracker {
122
123
  pendingFile.c = args.file.completed;
123
124
  pendingFile.er = args.file.failed;
124
125
  pendingFile.ok = args.file.lastOkChunk;
126
+ pendingFile.ec = this.#toTrackedFailureCode(args.reason);
125
127
  this.#progress.activeTime = args.activeTime;
126
128
  this.#progressChanged = true;
127
129
  };
@@ -130,6 +132,7 @@ class DownloadTracker {
130
132
  pendingFile.c = args.file.completed;
131
133
  pendingFile.er = args.file.failed;
132
134
  pendingFile.ok = args.file.lastOkChunk;
135
+ pendingFile.ec = null;
133
136
  this.#progress.activeTime = args.activeTime;
134
137
  this.#progressChanged = true;
135
138
  };
@@ -142,8 +145,26 @@ class DownloadTracker {
142
145
  };
143
146
  #onCompleted = async (args) => {
144
147
  const removeTracking = args.status === TransferStatus.Completed;
148
+ if (!removeTracking)
149
+ await this.#dumpAllProgress();
145
150
  await this.#cleanUp(removeTracking);
146
151
  };
152
+ #toTrackedFailureCode(error) {
153
+ if (error.errorCode !== null)
154
+ return error.errorCode;
155
+ if (_a.#extractErrorCode(error) === `ENOSPC`)
156
+ return DownloadErrorCode.DiskFull;
157
+ return null;
158
+ }
159
+ static #extractErrorCode(error) {
160
+ let current = error;
161
+ for (let depth = 0; depth < 8 && current; depth++) {
162
+ if (typeof current.code === `string`)
163
+ return current.code;
164
+ current = current.cause;
165
+ }
166
+ return undefined;
167
+ }
147
168
  async #cleanUp(removeTracking) {
148
169
  this.#running = false;
149
170
  this.#progressChanged = false;
@@ -226,6 +247,12 @@ class DownloadTracker {
226
247
  file.isCompleted = fileTrack.c;
227
248
  file.isFailed = fileTrack.er;
228
249
  file.lastSuccessfulChunkNumber = fileTrack.ok;
250
+ if (this.#shouldRetryFailedFile(fileTrack)) {
251
+ fileTrack.er = false;
252
+ fileTrack.ec = null;
253
+ file.isFailed = false;
254
+ fileWasReset = true;
255
+ }
229
256
  if (file.isCompleted || file.isFailed)
230
257
  // let's save some cpu time on restoring chunk collection for file which will never be picked up
231
258
  file.downloadedBytes_bank = file.sizeInBytes;
@@ -259,6 +286,9 @@ class DownloadTracker {
259
286
  chunk.setProgress(chunk.chunkSize);
260
287
  return chunk;
261
288
  }
289
+ #shouldRetryFailedFile(fileTrack) {
290
+ return fileTrack.er === true && fileTrack.c === false;
291
+ }
262
292
  async start(allFiles) {
263
293
  this.#throwIfRunning();
264
294
  this.#running = true;
@@ -269,6 +299,7 @@ class DownloadTracker {
269
299
  er: file.isFailed,
270
300
  ok: file.lastSuccessfulChunkNumber,
271
301
  wr: file.wasEverWritten,
302
+ ec: null,
272
303
  };
273
304
  this.#allFiles[file.externalId] = {
274
305
  u: file.url,