Skip to content

Commit

Permalink
GStreamer: add retry to file download
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed May 22, 2024
1 parent 9b30458 commit 76f74ca
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions ExtLibs/Utilities/GStreamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,26 +2163,34 @@ public static void DownloadGStreamer(Action<int, string> status = null)


status?.Invoke(0, "Downloading..");
int retry = 3;

try
{
Download.getFilefromNet(url, output, status: status);

status?.Invoke(50, "Extracting..");
ZipFile.ExtractToDirectory(output, Settings.GetDataDirectory());
status?.Invoke(100, "Done.");
}
catch (WebException ex)
while (retry > 0)
{
status?.Invoke(-1, "Error downloading file " + ex.ToString());
try
{
if (File.Exists(output))
File.Delete(output);
Download.getFilefromNet(url, output, status: status);

status?.Invoke(50, "Extracting..");
ZipFile.ExtractToDirectory(output, Settings.GetDataDirectory());
status?.Invoke(100, "Done.");

break;
}
catch
catch (Exception ex)
{
}
status?.Invoke(-1, "Error downloading file " + ex.ToString());
try
{
if (File.Exists(output))
File.Delete(output);
}
catch
{
}
status?.Invoke(-1, "Retry");
}
retry--;
}
}
}
Expand Down

0 comments on commit 76f74ca

Please sign in to comment.