Skip to content

Commit

Permalink
build download fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Trowbridge committed Dec 19, 2022
1 parent fd99798 commit c8fca12
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acuamtica-dev-tools",
"version": "1.0.3",
"version": "1.0.4",
"description": "Acumatica ERP Development Tools",
"license": "MIT",
"author": {
Expand Down
63 changes: 41 additions & 22 deletions src/main/actions/downloadBuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export default function DownloadBuild(database: sqlite.Database, mainWindow: Bro
}

async function start(database: sqlite.Database, mainWindow: BrowserWindow, event: IpcMainEvent, selectedBuild: BuildRow, extractMsi: boolean) {
const sendError = (text: string) => {
SendToast(mainWindow, {
text: text,
options: {
variant: 'error',
},
});
};

try {
console.log(`Downloading build`, selectedBuild);

Expand Down Expand Up @@ -56,36 +65,46 @@ async function start(database: sqlite.Database, mainWindow: BrowserWindow, event

event.reply('downloadBuild-status', ['Moving Files...']);
console.log('Moving Files...');
if (fs.existsSync(`AcumaticaERPInstall/SourceDir/Acumatica ERP`)) {
fs.move(`AcumaticaERPInstall/SourceDir/Acumatica ERP`, `${settings.buildLocation}/${selectedBuild.build}`);
} else {
fs.move(`AcumaticaERPInstall/SourceDir`, `${settings.buildLocation}/${selectedBuild.build}`);
}
console.log('Removing temp files...');
event.reply('downloadBuild-status', ['Removing temp files...']);

fs.rm(`AcumaticaERPInstall`, { recursive: true, force: true });
fs.rm(`AcumaticaERPInstall.msi`, { recursive: true, force: true });

console.log(`COMPLETE! - AcumaticaERPInstall-${selectedBuild.build}.msi`);
event.reply('downloadBuild-complete', [`${settings.buildLocation}/${selectedBuild.build}`]);
const source = fs.existsSync(`AcumaticaERPInstall/SourceDir/Acumatica ERP`) ? `AcumaticaERPInstall/SourceDir/Acumatica ERP` : `AcumaticaERPInstall/SourceDir`;
fs.move(source, `${settings.buildLocation}/${selectedBuild.build}`, { overwrite: true })
.then(() => {
console.log('Removing temp files...');
event.reply('downloadBuild-status', ['Removing temp files...']);
fs.rm(`AcumaticaERPInstall`, { recursive: true, force: true })
.then(() => {
fs.rm(`AcumaticaERPInstall.msi`, { recursive: true, force: true })
.then(() => {
console.log(`COMPLETE! - AcumaticaERPInstall-${selectedBuild.build}.msi`);
event.reply('downloadBuild-complete', [`${settings.buildLocation}/${selectedBuild.build}`]);
})
.catch((e) => {
sendError(String(e));
});
})
.catch((e) => {
sendError(String(e));
});
})
.catch((e) => {
sendError(String(e));
});
});
child.stdin.end(); //end input
} else {
fs.move(`AcumaticaERPInstall.msi`, path.join(app.getPath('downloads'), `AcumaticaERPInstall-${selectedBuild.build}.msi`));
console.log(`COMPLETE! - AcumaticaERPInstall-${selectedBuild.build}.msi`);
event.reply('downloadBuild-complete', [app.getPath('downloads')]);
fs.move(`AcumaticaERPInstall.msi`, path.join(app.getPath('downloads'), `AcumaticaERPInstall-${selectedBuild.build}.msi`), { overwrite: true })
.then(() => {
console.log(`COMPLETE! - AcumaticaERPInstall-${selectedBuild.build}.msi`);
event.reply('downloadBuild-complete', [app.getPath('downloads')]);
})
.catch((e) => {
sendError(String(e));
});
}
});
} catch (e) {
console.log(e);

SendToast(mainWindow, {
text: 'Error querying Acuamtica instances! > ' + (e as Error).message,
options: {
variant: 'error',
},
});
sendError('Error querying Acuamtica instances! > ' + (e as Error).message);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/renderer/Components/BuildSearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default function BuildSearchDialog(props: BuildSearchDialogProps) {
const [alertOpen, setAlertOpen] = React.useState(false);

const [downloadProgressOpen, setDownloadProgressOpen] = React.useState(false);
const [statuses, setStatuses] = React.useState<string[]>([]);

const updateExtractMsi = async (extractMsi: boolean) => {
setExtractMsi(extractMsi);
Expand Down

0 comments on commit c8fca12

Please sign in to comment.