Skip to content

Commit c5bcc60

Browse files
committed
Fix version management when installing .plugdata packages
1 parent daeda81 commit c5bcc60

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Source/Components/WelcomePanel.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class WelcomePanel final : public Component
364364
previousVersions.clear();
365365

366366
for (auto& [time, file] : versions) {
367-
auto metaFile = file.getParentDirectory().getChildFile("meta.json");
367+
auto metaFile = file.getSiblingFile("meta.json");
368368
if (metaFile.existsAsFile()) {
369369
auto const json = JSON::fromString(metaFile.loadFileAsString());
370370
if (json.hasProperty("Version")) {
@@ -929,13 +929,14 @@ class WelcomePanel final : public Component
929929
libraryTiles.clear();
930930

931931
auto addTile = [this](Array<std::pair<int64, File>> patches) {
932-
auto patchFile = patches[0].second;
933-
auto const pName = patchFile.getFileNameWithoutExtension();
934-
auto foundThumbs = patchFile.getParentDirectory().findChildFiles(File::findFiles, true, pName + "_thumb.png;" + pName + "_thumb.jpg;" + pName + "_thumb.jpeg;" + pName + "_thumb.gif");
935-
932+
936933
std::ranges::sort(patches, [](std::pair<int64, File> const& first, std::pair<int64, File> const& second) {
937934
return first.first > second.first;
938935
});
936+
937+
auto patchFile = patches[0].second;
938+
auto const pName = patchFile.getFileNameWithoutExtension();
939+
auto foundThumbs = patchFile.getParentDirectory().findChildFiles(File::findFiles, true, pName + "_thumb.png;" + pName + "_thumb.jpg;" + pName + "_thumb.jpeg;" + pName + "_thumb.gif");
939940

940941
patches.remove(0);
941942

Source/PluginEditor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,14 +862,15 @@ void PluginEditor::installPackage(File const& file)
862862
{
863863
auto zip = ZipFile(file);
864864
auto patchesDir = ProjectInfo::appDataDir.getChildFile("Patches");
865-
auto const result = zip.uncompressTo(patchesDir, false);
865+
auto extractedDir = File::createTempFile("");
866+
auto const result = zip.uncompressTo(extractedDir, false);
866867
if (result.wasOk()) {
867868
auto const macOSTrash = ProjectInfo::appDataDir.getChildFile("Patches").getChildFile("__MACOSX");
868869
if (macOSTrash.isDirectory()) {
869870
macOSTrash.deleteRecursively();
870871
}
871872

872-
auto extractedLocation = patchesDir.getChildFile(zip.getEntry(0)->filename);
873+
auto extractedLocation = extractedDir.getChildFile(zip.getEntry(0)->filename);
873874
auto const metaFile = extractedLocation.getChildFile("meta.json");
874875
if (!metaFile.existsAsFile()) {
875876
PatchInfo info;
@@ -882,8 +883,10 @@ void PluginEditor::installPackage(File const& file)
882883
info.setInstallTime(Time::currentTimeMillis());
883884
auto json = info.json;
884885
metaFile.replaceWithText(info.json);
886+
extractedLocation.moveFileTo(patchesDir.getChildFile(info.getNameInPatchFolder()));
885887
}
886888

889+
887890
Dialogs::showMultiChoiceDialog(&openedDialog, this, "Successfully installed " + file.getFileNameWithoutExtension(), [](int) { }, { "Dismiss" }, Icons::Checkmark);
888891
}
889892
else {

0 commit comments

Comments
 (0)