@@ -856,35 +856,53 @@ void PluginEditor::fileDragMove(StringArray const& files, int const x, int const
856856
857857void PluginEditor::installPackage (File const & file)
858858{
859- auto zip = ZipFile (file);
860- auto patchesDir = ProjectInfo::appDataDir.getChildFile (" Patches" );
861- auto extractedDir = File::createTempFile (" " );
862- auto const result = zip.uncompressTo (extractedDir, false );
863- if (result.wasOk ()) {
864- auto const macOSTrash = ProjectInfo::appDataDir.getChildFile (" Patches" ).getChildFile (" __MACOSX" );
865- if (macOSTrash.isDirectory ()) {
866- macOSTrash.deleteRecursively ();
867- }
868-
869- auto extractedLocation = extractedDir.getChildFile (zip.getEntry (0 )->filename );
870- auto const metaFile = extractedLocation.getChildFile (" meta.json" );
871- if (!metaFile.existsAsFile ()) {
872- PatchInfo info;
873- info.title = file.getFileNameWithoutExtension ();
874- info.setInstallTime (Time::currentTimeMillis ());
875- auto json = info.json ;
876- metaFile.replaceWithText (info.json );
859+ auto install = [this , file]{
860+ auto zip = ZipFile (file);
861+ auto patchesDir = ProjectInfo::appDataDir.getChildFile (" Patches" );
862+ auto extractedDir = File::createTempFile (" " );
863+ auto const result = zip.uncompressTo (extractedDir, false );
864+ if (result.wasOk ()) {
865+ auto const macOSTrash = ProjectInfo::appDataDir.getChildFile (" Patches" ).getChildFile (" __MACOSX" );
866+ if (macOSTrash.isDirectory ()) {
867+ macOSTrash.deleteRecursively ();
868+ }
869+
870+ auto extractedLocation = extractedDir.getChildFile (zip.getEntry (0 )->filename );
871+ auto const metaFile = extractedLocation.getChildFile (" meta.json" );
872+ if (!metaFile.existsAsFile ()) {
873+ PatchInfo info;
874+ info.title = file.getFileNameWithoutExtension ();
875+ info.setInstallTime (Time::currentTimeMillis ());
876+ auto json = info.json ;
877+ metaFile.replaceWithText (info.json );
878+ } else {
879+ auto info = PatchInfo (JSON::fromString (metaFile.loadFileAsString ()));
880+ info.setInstallTime (Time::currentTimeMillis ());
881+ auto json = info.json ;
882+ metaFile.replaceWithText (info.json );
883+ extractedLocation.moveFileTo (patchesDir.getChildFile (info.getNameInPatchFolder ()));
884+ }
885+ MessageManager::callAsync ([this , file]{
886+ Dialogs::showMultiChoiceDialog (&openedDialog, this , " Successfully installed " + file.getFileNameWithoutExtension (), [](int ) { }, { " Dismiss" }, Icons::Checkmark);
887+ });
888+
877889 } else {
878- auto info = PatchInfo (JSON::fromString (metaFile.loadFileAsString ()));
879- info.setInstallTime (Time::currentTimeMillis ());
880- auto json = info.json ;
881- metaFile.replaceWithText (info.json );
882- extractedLocation.moveFileTo (patchesDir.getChildFile (info.getNameInPatchFolder ()));
890+ MessageManager::callAsync ([this , file]{
891+ Dialogs::showMultiChoiceDialog (&openedDialog, this , " Failed to install " + file.getFileNameWithoutExtension (), [](int ) { }, { " Dismiss" });
892+ });
883893 }
884-
885- Dialogs::showMultiChoiceDialog (&openedDialog, this , " Successfully installed " + file.getFileNameWithoutExtension (), [](int ) { }, { " Dismiss" }, Icons::Checkmark);
886- } else {
887- Dialogs::showMultiChoiceDialog (&openedDialog, this , " Failed to install " + file.getFileNameWithoutExtension (), [](int ) { }, { " Dismiss" });
894+ };
895+
896+ if (OSUtils::isFileQuarantined (file))
897+ {
898+ Dialogs::showMultiChoiceDialog (&openedDialog, this , " This patch was downloaded from the internet. Installing patches from untrusted sources may pose security risks. Do you want to proceed?" , [install, file](int const choice) {
899+ if (choice == 0 ) {
900+ OSUtils::removeFromQuarantine (file);
901+ install ();
902+ } }, { " Trust and Install" , " Cancel" }, Icons::Warning);
903+ }
904+ else {
905+ install ();
888906 }
889907}
890908
0 commit comments