{"id":20176342,"url":"https://github.com/theogravity/electron-dl-manager","last_synced_at":"2026-03-01T03:32:13.778Z","repository":{"id":228724554,"uuid":"774706122","full_name":"theogravity/electron-dl-manager","owner":"theogravity","description":"A library for implementing (multi-) file downloads in Electron with 'save as' dialog and id support.","archived":false,"fork":false,"pushed_at":"2025-11-26T19:58:16.000Z","size":645,"stargazers_count":25,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-29T05:28:16.652Z","etag":null,"topics":["download","downloader","electron","electron-dl","files","library","manager","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theogravity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-20T02:54:59.000Z","updated_at":"2025-11-26T19:58:20.000Z","dependencies_parsed_at":"2024-04-03T22:22:58.209Z","dependency_job_id":"23667029-c54c-47d6-ac62-1bd287a3e1b5","html_url":"https://github.com/theogravity/electron-dl-manager","commit_stats":null,"previous_names":["theogravity/electron-multi-downloader","theogravity/electron-dl-manager"],"tags_count":2,"template":false,"template_full_name":"tomchen/example-typescript-package","purl":"pkg:github/theogravity/electron-dl-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theogravity%2Felectron-dl-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theogravity%2Felectron-dl-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theogravity%2Felectron-dl-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theogravity%2Felectron-dl-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theogravity","download_url":"https://codeload.github.com/theogravity/electron-dl-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theogravity%2Felectron-dl-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29959370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["download","downloader","electron","electron-dl","files","library","manager","typescript"],"created_at":"2024-11-14T02:08:43.799Z","updated_at":"2026-03-01T03:32:13.763Z","avatar_url":"https://github.com/theogravity.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Electron File Download Manager\n\n[![NPM version](https://img.shields.io/npm/v/electron-dl-manager.svg?style=flat-square)](https://www.npmjs.com/package/electron-dl-manager) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)\n\nA simple and easy to use file download manager for Electron applications.\nDesigned in response to the many issues around `electron-dl` and provides\na more robust and reliable solution for downloading files in Electron.\n\nUse cases:\n\n- Download files from a URL\n- Get an id associated with the download to track it\n- Optionally show a \"Save As\" dialog\n- Get progress updates on the download\n- Be able to cancel / pause / resume downloads\n- Support multiple downloads at once\n- Persist downloads when the app closes, allowing them to be restored / resumed later\n\nElectron 26.0.0 or later is required.\n\n```typescript\n// In main process\n// Not a working example, just a demonstration of the API\nimport { ElectronDownloadManager } from 'electron-dl-manager';\n\nconst manager = new ElectronDownloadManager();\n\n// Start a download\nconst id = await manager.download({\n  window: browserWindowInstance,\n  url: 'https://example.com/file.zip',\n  saveDialogOptions: {\n    title: 'Save File',\n  },\n  callbacks: {\n    onDownloadStarted: async ({ id, item, webContents }) =\u003e {\n      // Do something with the download id\n    },\n    onDownloadProgress: async (...) =\u003e {},\n    onDownloadCompleted: async (...) =\u003e {},\n    onDownloadCancelled: async (...) =\u003e {},\n    onDownloadInterrupted: async (...) =\u003e {},\n    onError: (err, data) =\u003e {},\n  }\n});\n\nmanager.cancelDownload(id);\nmanager.pauseDownload(id);\nmanager.resumeDownload(id);\n```\n\n# Table of contents\n\n- [Electron File Download Manager](#electron-file-download-manager)\n- [Installation](#installation)\n- [Getting started](#getting-started)\n- [Download Restoration \u0026 Persistence](#download-restoration--persistence)\n  - [Basic Download Restoration](#basic-download-restoration)\n  - [Download Persistence](#download-persistence)\n- [API](#api)\n  - [Class: `ElectronDownloadManager`](#class-ElectronDownloadManager)\n    - [`constructor()`](#constructor)\n    - [`download()`](#download)\n      - [Interface: `DownloadParams`](#interface-downloadparams)\n      - [Interface: `DownloadManagerCallbacks`](#interface-downloadmanagercallbacks)\n    - [`cancelDownload()`](#canceldownload)\n    - [`pauseDownload()`](#pausedownload)\n    - [`resumeDownload()`](#resumedownload)\n    - [`restoreDownload()`](#restoredownload)\n    - [`getActiveDownloadCount()`](#getactivedownloadcount)\n    - [`getDownloadData()`](#getdownloaddata)\n  - [Class: `DownloadData`](#class-downloaddata)\n    - [Properties](#properties)\n      - [Formatting download progress](#formatting-download-progress)\n    - [`isDownloadInProgress()`](#isdownloadinprogress)\n    - [`isDownloadPaused()`](#isdownloadpaused)\n    - [`isDownloadResumable()`](#isdownloadresumable)\n    - [`isDownloadCancelled()`](#isdownloadcancelled)\n    - [`isDownloadInterrupted()`](#isdownloadinterrupted)\n    - [`isDownloadCompleted()`](#isdownloadcompleted)\n    - [`getRestoreDownloadData()`](#getrestoredownloaddata)\n- [Mock class](#mock-class)\n- [FAQ](#faq)\n- [Acknowledgments](#acknowledgments)\n\n# Installation\n\n```bash\n$ npm install electron-dl-manager\n```\n\n# Getting started\n\nYou'll want to use `electron-dl-manager` in the main process of your\nElectron application where you will be handling the file downloads.\n\nIn this example, we use [IPC handlers / invokers](https://www.electronjs.org/docs/latest/tutorial/ipc#pattern-2-renderer-to-main-two-way)\nto communicate between the main and renderer processes, but you can\nuse any IPC strategy you want.\n\n```typescript\n// MainIpcHandlers.ts\n\nimport { ElectronDownloadManager } from 'electron-dl-manager';\nimport { ipcMain } from 'electron';\n\nconst manager = new ElectronDownloadManager();\n\n// Renderer would invoke this handler to start a download\nipcMain.handle('download-file', async (event, args) =\u003e {\n  const { url } = args;\n\n  let downloadId\n  const browserWindow = BrowserWindow.fromId(event.sender.id)\n\n  // You *must* call manager.download() with await or \n  // you may get unexpected behavior\n  downloadId = await manager.download({\n    window: browserWindow,\n    url,\n    // If you want to download without a save as dialog\n    saveAsFilename: 'file.zip',\n    directory: '/directory/where/to/save',\n    // If you want to download with a save as dialog\n    saveDialogOptions: {\n      title: 'Save File',\n    },\n    callbacks: {\n      // item is an instance of Electron.DownloadItem\n      onDownloadStarted: async ({ id, item, resolvedFilename }) =\u003e {\n        // Send the download id back to the renderer along\n        // with some other data\n        browserWindow.webContents.invoke('download-started', {\n          id,\n          // The filename that the file will be saved as\n          filename: resolvedFilename,\n          // Get the file size to be downloaded in bytes\n          totalBytes: item.getTotalBytes(),\n        });\n      },\n      onDownloadProgress: async ({ id, item, percentCompleted }) =\u003e {\n        // Send the download progress back to the renderer\n        browserWindow.webContents.invoke('download-progress', {\n          id,\n          percentCompleted,\n          // Get the number of bytes received so far\n          bytesReceived: item.getReceivedBytes(),\n        });\n      },\n      onDownloadCompleted: async ({ id, item }) =\u003e {\n        // Send the download completion back to the renderer\n        browserWindow.webContents.invoke('download-completed', {\n          id,\n          // Get the path to the file that was downloaded\n          filePath: item.getSavePath(),\n        });\n      },\n      onError: (err, data) =\u003e {\n        // ... handle any errors\n      }\n    }\n  });\n\n  // Pause the download\n  manager.pauseDownload(downloadId);\n});\n```\n\n# Download Restoration \u0026 Persistence\n\nThis section covers advanced download management features that go beyond simple pause/resume functionality. These features are essential for applications that need to handle downloads across different browser windows, app restarts, or when downloads are interrupted by external factors.\n\n## When to Use These Features\n\n### Regular Pause/Resume vs. Restoration\n- \n- **Pause/Resume**: Use `pauseDownload()` and `resumeDownload()` when you want to temporarily stop and restart a download within the same browser window and session.\n- **Restoration**: Use `restoreDownload()` when you need to resume a download in a different browser window, after the original window has been closed, or when the download manager instance has been destroyed.\n- **Persistence**: Use the `persistOnAppClose` option in `download()` when you want downloads to automatically survive app restarts, crashes, or when the user closes the application.\n\n## Basic Download Restoration\n\n### Interface: `RestoreDownloadConfig`\n\n```typescript\ninterface RestoreDownloadConfig {\n  /**\n   * The Electron.App instance\n   */\n  app: Electron.App\n  /**\n   * The Electron.BrowserWindow instance where the download should be restored\n   */\n  window: BrowserWindow\n  /**\n   * Data required for resuming the download, returned from pauseDownload()\n   */\n  restoreData: RestoreDownloadData\n  /**\n   * The callbacks to define to listen for download events\n   */\n  callbacks: DownloadManagerCallbacks\n  /**\n   * Electron.DownloadURLOptions to pass to the downloadURL method\n   *\n   * @see https://www.electronjs.org/docs/latest/api/session#sesdownloadurlurl-options\n   */\n  downloadURLOptions?: Electron.DownloadURLOptions\n}\n```\n\n### Interface: `RestoreDownloadData`\n\n```typescript\ninterface RestoreDownloadData {\n  /**\n   * Download id\n   */\n  id: string\n  /**\n   * The URL of the download\n   */\n  url: string\n  /**\n   * The path and filename where the download will be saved\n   */\n  fileSaveAsPath: string\n  /**\n   * The chain of URLs that led to this download\n   */\n  urlChain: string[]\n  /**\n   * The MIME type of the file being downloaded\n   */\n  mimeType: string\n  /**\n   * The ETag of the download, if available. This is used to resume downloads\n   */\n  eTag: string\n  /**\n   * The number of bytes already received\n   */\n  receivedBytes: number\n  /**\n   * The total number of bytes to download\n   */\n  totalBytes: number\n  /**\n   * The timestamp when the download started\n   */\n  startTime: number\n  /**\n   * The percentage of the download that has been completed\n   */\n  percentCompleted: number\n  /**\n   * If persistOnAppClose is true, this is the path where the download\n   * is persisted to. This is used to restore the download later.\n   */\n  persistedFilePath?: string\n}\n```\n\n### Example: Basic Download Restoration\n\n```typescript\n// Pause a download and get restore data\nconst restoreData = manager.pauseDownload(downloadId);\n\nif (restoreData) {\n  // Later, in a different browser window\n  const newDownloadId = await manager.restoreDownload({\n    app,\n    window: newBrowserWindow,\n    restoreData,\n    callbacks: {\n      onDownloadStarted: async ({ id, item, resolvedFilename }) =\u003e {\n        console.log(`Restored download ${id} started`);\n      },\n      onDownloadProgress: async ({ id, percentCompleted }) =\u003e {\n        console.log(`Restored download ${id} progress: ${percentCompleted}%`);\n      },\n      onDownloadCompleted: async ({ id, item }) =\u003e {\n        console.log(`Restored download ${id} completed`);\n      },\n      onError: (err, data) =\u003e {\n        console.error('Error in restored download:', err);\n      }\n    }\n  });\n}\n```\n\n## Download Persistence\n\nVersion 4.2.0 introduces the ability to automatically persist downloads when the application closes, allowing them to be restored later. This feature is fundamentally different from manual pause/resume because it:\n\n- **Automatically triggers** when the app is about to close (listens to the `will-quit` event)\n- **Preserves download state** including progress, file paths, and metadata\n- **Survives app crashes** and unexpected shutdowns\n- **Works across app restarts** without requiring user intervention\n- **Handles file management** by creating temporary `.download` files that are automatically restored\n\n### Enabling Download Persistence\n\nTo enable download persistence, set `persistOnAppClose: true` and provide the `app` instance:\n\n```typescript\nconst id = await manager.download({\n  app, // Electron.App instance\n  window: mainWindow,\n  url: 'https://example.com/large-file.zip',\n  saveAsFilename: 'large-file.zip',\n  persistOnAppClose: true,\n  callbacks: {\n    onDownloadPersisted: async (data, restoreData) =\u003e {\n      console.log('Download persisted:', restoreData.persistedFilePath);\n      // Save restoreData to a file or database for later restoration\n      writeFileSync('download-metadata.json', JSON.stringify(restoreData));\n    },\n    onDownloadCompleted: async (data) =\u003e {\n      console.log('Download completed');\n    },\n    onError: (err, data) =\u003e {\n      console.error('Download error:', err);\n    }\n  }\n});\n```\n\n### Restoring Persisted Downloads\n\nWhen the app restarts, you can restore persisted downloads using the saved metadata:\n\n```typescript\n// Read the saved metadata\nconst metadata = JSON.parse(readFileSync('download-metadata.json', 'utf-8'));\n\n// Restore the download\nawait manager.restoreDownload({\n  app,\n  window: mainWindow,\n  restoreData: metadata,\n  callbacks: {\n    onDownloadStarted: async (data) =\u003e {\n      console.log('Persisted download restored and started');\n    },\n    onDownloadProgress: async (data) =\u003e {\n      console.log(`Progress: ${data.percentCompleted}%`);\n    },\n    onDownloadCompleted: async (data) =\u003e {\n      console.log('Persisted download completed');\n    },\n    onError: (err, data) =\u003e {\n      console.error('Error in restored download:', err);\n    }\n  }\n});\n```\n\n**Note:** The `persistedFilePath` in the restore data points to a temporary file with a `.download` extension. The library automatically handles moving this file to the correct location when restoring.\n\n# API\n\n## Class: `ElectronDownloadManager`\n\nManages file downloads in an Electron application.\n\n### `constructor()`\n\n```typescript\nconstructor(params: DownloadManagerConstructorParams)\n```\n\n```typescript\ninterface DownloadManagerConstructorParams {\n  /**\n   * If defined, will log out internal debug messages. Useful for\n   * troubleshooting downloads. Does not log out progress due to\n   * how frequent it can be.\n   */\n  debugLogger?: (message: string) =\u003e void\n}\n```\n\n### `download()`\n\nStarts a file download. Returns the `id` of the download.\n\n```typescript\ndownload(params: DownloadParams): Promise\u003cstring\u003e\n```\n\n#### Interface: `DownloadParams`\n\n```typescript\ninterface DownloadParams {\n  /**\n   * The Electron.BrowserWindow instance\n   */\n  window: BrowserWindow\n  /**\n   * The URL to download\n   */\n  url: string\n  /**\n   * The callbacks to define to listen for download events\n   */\n  callbacks: DownloadManagerCallbacks\n  /**\n   * Electron.DownloadURLOptions to pass to the downloadURL method\n   *\n   * @see https://www.electronjs.org/docs/latest/api/session#sesdownloadurlurl-options\n   */\n  downloadURLOptions?: Electron.DownloadURLOptions\n  /**\n   * If defined, will show a save dialog when the user\n   * downloads a file.\n   *\n   * @see https://www.electronjs.org/docs/latest/api/dialog#dialogshowsavedialogbrowserwindow-options\n   */\n  saveDialogOptions?: SaveDialogOptions\n  /**\n   * The filename to save the file as. If not defined, the filename\n   * from the server will be used.\n   *\n   * Only applies if saveDialogOptions is not defined.\n   */\n  saveAsFilename?: string\n  /**\n   * The directory to save the file to. Must be an absolute path.\n   * @default The user's downloads directory\n   */\n  directory?: string\n  /**\n   * If true, will overwrite the file if it already exists\n   * @default false\n   */\n  overwrite?: boolean\n  /**\n   * If true, will persist the download when the app closes, allowing it to be restored later.\n   * Requires the `app` parameter to be provided.\n   * @default false\n   */\n  persistOnAppClose?: boolean\n  /**\n   * The Electron.App instance. Required if persistOnAppClose is enabled.\n   */\n  app?: Electron.App\n}\n```\n\n#### Interface: `DownloadManagerCallbacks`\n\n```typescript\ninterface DownloadManagerCallbacks {\n  /**\n   * When the download has started. When using a \"save as\" dialog,\n   * this will be called after the user has selected a location.\n   *\n   * This will always be called first before the progress and completed events.\n   */\n  onDownloadStarted: (data: DownloadData) =\u003e void\n  /**\n   * When there is a progress update on a download. Note: This\n   * may be skipped entirely in some cases, where the download\n   * completes immediately. In that case, onDownloadCompleted\n   * will be called instead.\n   */\n  onDownloadProgress: (data: DownloadData) =\u003e void\n  /**\n   * When the download has completed\n   */\n  onDownloadCompleted: (data: DownloadData) =\u003e void\n  /**\n   * When the download has been cancelled. Also called if the user cancels\n   * from the save as dialog.\n   */\n  onDownloadCancelled: (data: DownloadData) =\u003e void\n  /**\n   * When the download has been interrupted. This could be due to a bad\n   * connection, the server going down, etc.\n   */\n  onDownloadInterrupted: (data: DownloadData) =\u003e void\n  /**\n   * When the download has been persisted for later restoration.\n   * This callback is called when persistOnAppClose is enabled and the app is about to close.\n   */\n  onDownloadPersisted?: (data: DownloadData, restoreDownloadData: RestoreDownloadData) =\u003e void\n  /**\n   * When an error has been encountered.\n   * Note: The signature is (error, \u003cmaybe some data\u003e).\n   */\n  onError: (error: Error, data?: DownloadData) =\u003e void\n}\n```\n\n### `cancelDownload()`\n\nCancels a download.\n\n```typescript\ncancelDownload(id: string): void\n```\n\n### `pauseDownload()`\n\nPauses a download and returns the data necessary to restore it later via `restoreDownload()`.\n\n```typescript\npauseDownload(id: string): RestoreDownloadData | undefined\n```\n\n**Returns:** `RestoreDownloadData` if the download exists and can be paused, `undefined` if the download is not found.\n\n**Note:** Use the returned data with `restoreDownload()` to restore a download.\n\n### `resumeDownload()`\n\nResumes a download.\n\n```typescript\nresumeDownload(id: string): void\n```\n\n### `restoreDownload()`\n\nRestores a download that is not registered in the download manager using data returned from `pauseDownload()`. This is useful when you need to restore a download in a different browser window or after the original window has been closed.\n\nIf the download is already registered in the current download manager, this method will call `resumeDownload()` instead.\n\n```typescript\nrestoreDownload(params: RestoreDownloadConfig): Promise\u003cstring\u003e\n```\n\n**Note:** See the [Download Restoration \u0026 Persistence](#download-restoration--persistence) section for detailed information about restoring downloads and using the persistence feature.\n\n### `getActiveDownloadCount()`\n\nReturns the number of active downloads.\n\n```typescript\ngetActiveDownloadCount(): number\n```\n\n### `getDownloadData()`\n\nReturns the download data for a download.\n\n```typescript\ngetDownloadData(id: string): DownloadData\n```\n\n## Class: `DownloadData`\n\nData returned in the callbacks for a download.\n\n### Properties\n\n```typescript\nclass DownloadData {\n  /**\n   * Generated id for the download\n   */\n  id: string\n  /**\n   * The Electron.DownloadItem. Use this to grab the filename, path, etc.\n   * @see https://www.electronjs.org/docs/latest/api/download-item\n   */\n  item: DownloadItem\n  /**\n   * The Electron.WebContents\n   * @see https://www.electronjs.org/docs/latest/api/web-contents\n   */\n  webContents: WebContents\n  /**\n   * The Electron.Event\n   * @see https://www.electronjs.org/docs/latest/api/event\n   */\n  event: Event\n  /**\n   * The name of the file that is being saved to the user's computer.\n   * Recommended over Item.getFilename() as it may be inaccurate when using the save as dialog.\n   */\n  resolvedFilename: string\n  /**\n   * If true, the download was cancelled from the save as dialog. This flag\n   * will also be true if the download was cancelled by the application when\n   * using the save as dialog.\n   */\n  cancelledFromSaveAsDialog?: boolean\n  /**\n   * The percentage of the download that has been completed\n   */\n  percentCompleted: number\n  /**\n   * The download rate in bytes per second.\n   */\n  downloadRateBytesPerSecond: number\n  /**\n   * The estimated time remaining in seconds.\n   */\n  estimatedTimeRemainingSeconds: number\n  /**\n   * If the download was interrupted, the state in which it was interrupted from\n   */\n  interruptedVia?: 'in-progress' | 'completed'\n  /**\n   * If defined, this is the path where the download is persisted to.\n   * This is set when persistOnAppClose is enabled and the download is persisted.\n   */\n  persistedFilePath?: string\n}\n```\n\n#### Formatting download progress\n\nYou can use the libraries [`bytes`](https://www.npmjs.com/package/bytes) and [`dayjs`](https://www.npmjs.com/package/dayjs) to format the download progress.\n\n```bash\n$ pnpm add bytes dayjs\n$ pnpm add -D @types/bytes\n```\n\n```typescript\nimport bytes from 'bytes'\nimport dayjs from 'dayjs'\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport duration from 'dayjs/plugin/duration';\n\ndayjs.extend(relativeTime);\ndayjs.extend(duration);\n\nconst downloadData = manager.getDownloadData(id); // or DataItem from the callbacks\n\n// Will return something like 1.2 MB/s\nconst formattedDownloadRate = bytes(downloadData.downloadRateBytesPerSecond, { unitSeparator: ' ' }) + '/s'\n\n// Will return something like \"in a few seconds\"\nconst formattedEstimatedTimeRemaining = dayjs.duration(downloadData.estimatedTimeRemainingSeconds, 'seconds').humanize(true)\n```\n\n### `isDownloadInProgress()`\n\nReturns true if the download is in progress.\n\n```typescript\nisDownloadInProgress(): boolean\n```\n\n### `isDownloadPaused()`\n\nReturns true if the download is paused.\n\n```typescript\nisDownloadPaused(): boolean\n```\n\n### `isDownloadResumable()`\n\nReturns true if the download is resumable.\n\n```typescript\nisDownloadResumable(): boolean\n```\n\n### `isDownloadCancelled()`\n\nReturns true if the download is cancelled.\n\n```typescript \nisDownloadCancelled(): boolean\n```\n\n### `isDownloadInterrupted()`\n\nReturns true if the download is interrupted.\n\n```typescript\nisDownloadInterrupted(): boolean\n```\n\n### `isDownloadCompleted()`\n\nReturns true if the download is completed.\n\n```typescript\nisDownloadCompleted(): boolean\n```\n\n### `getRestoreDownloadData()`\n\nReturns the data necessary to restore this download later via `restoreDownload()`. This method is typically called after pausing a download to get the data needed for restoration.\n\n```typescript\ngetRestoreDownloadData(): RestoreDownloadData\n```\n\n**Returns:** `RestoreDownloadData` containing all the information needed to restore the download, including the file path, URL, MIME type, ETag, and byte information.\n\n# Mock class\n\nIf you need to mock out `ElectronDownloadManager` in your tests, you can use the `ElectronDownloadManagerMock` class.\n\n`import { ElectronDownloadManagerMock } from 'electron-dl-manager'`\n\n# FAQ\n\n## How do I capture if the download is invalid? `onError()` is not being called.\n\nElectron `DownloadItem` doesn't provide an explicit way to capture errors for downloads in general:\n\nhttps://www.electronjs.org/docs/latest/api/download-item#class-downloaditem\n\n(It only has `on('updated')` and `on('done')` events, which this library uses for defining the callback handlers.)\n\nWhat it does for invalid URLs, it will trigger the `onDownloadCancelled()` callback.\n\n```typescript\nconst id = await manager.download({\n  window: mainWindow,\n  url: 'https://alkjsdflksjdflk.com/file.zip',\n  callbacks: {\n    onDownloadCancelled: async (...) =\u003e {\n      // Invalid download; this callback will be called\n    },\n  }\n});\n```\n\nA better way to handle this is to check if the URL exists prior to the download yourself.\nI couldn't find a library that I felt was reliable to include into this package,\nso it's best you find a library that works for you:\n\n- https://www.npmjs.com/search?q=url%20exists\u0026ranking=maintenance\n\nGPT also suggests the following code (untested):\n\n```typescript\nasync function urlExists(url: string): Promise\u003cboolean\u003e {\n  try {\n    const response = await fetch(url, { method: 'HEAD' });\n    return response.ok;\n  } catch (error) {\n    return false;\n  }\n}\n\nconst exists = await urlExists('https://example.com/file.jpg');\n```\n\n# Acknowledgments\n\nThis code uses small portions from [`electron-dl`](https://github.com/sindresorhus/electron-dl) and is noted in the\ncode where it is used.\n\n`electron-dl` is licensed under the MIT License and is maintained by Sindre Sorhus \u003csindresorhus@gmail.com\u003e (https://sindresorhus.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheogravity%2Felectron-dl-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheogravity%2Felectron-dl-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheogravity%2Felectron-dl-manager/lists"}