Skip to content

Commit 548f2a4

Browse files
committed
Add progress tracking during file download in Plugin Installer
1 parent a0e2022 commit 548f2a4

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

Source/UI/PluginInstaller.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,24 @@ int PluginInfoComponent::downloadPlugin (const String& plugin, const String& ver
14721472

14731473
//Use the Url's input stream and write it to a file using output stream
14741474
std::unique_ptr<FileOutputStream> out = pluginFile.createOutputStream();
1475-
out->writeFromInputStream (*fileStream, -1);
1475+
int64 total = 0;
1476+
int64 fileSize = fileStream->getTotalLength();
1477+
1478+
for (;;)
1479+
{
1480+
if (threadShouldExit())
1481+
return HTTP_ERR;
1482+
1483+
auto written = out->writeFromInputStream (*fileStream, 8192);
1484+
1485+
if (written == 0)
1486+
break;
1487+
1488+
total += written;
1489+
1490+
setProgress ((double) total / (double) fileSize);
1491+
}
1492+
14761493
out->flush();
14771494
out.reset();
14781495

@@ -1556,6 +1573,9 @@ int PluginInfoComponent::downloadPlugin (const String& plugin, const String& ver
15561573
if (tempDir.getChildFile ("shared").exists())
15571574
tempDir.getChildFile ("shared").deleteRecursively();
15581575

1576+
setProgress (-1.0);
1577+
setStatusMessage ("Uncompressing ZIP file...");
1578+
15591579
// Uncompress the plugin zip file to temp directory
15601580
juce::Result res = pluginZip.uncompressTo (tempDir);
15611581

0 commit comments

Comments
 (0)