This repository has been archived on 2025-09-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
repertory-ui/src/renderer/ipc/DownloadIPC.js
2021-08-04 17:17:16 -05:00

34 lines
866 B
JavaScript

const Constants = require('../../constants');
const helpers = require('../../helpers');
const path = require('path');
const addListeners = (ipcMain, {standardIPCReply}) => {
ipcMain.on(Constants.IPC_Download_File, (event, data) => {
const destination = path.join(helpers.getDataDirectory(), data.Filename);
helpers.downloadFile(
data.URL,
destination,
(progress) => {
standardIPCReply(event, Constants.IPC_Download_File_Progress, {
Destination: destination,
Progress: progress,
URL: data.URL,
});
},
(error) => {
standardIPCReply(
event,
Constants.IPC_Download_File_Complete,
{
Destination: destination,
URL: data.URL,
},
error
);
}
);
});
};
module.exports = {addListeners};