Fixed linux dependency donwloads, fixed slow download speeds
This commit is contained in:
@@ -94,34 +94,20 @@ namespace SplashEdit.EditorCode
|
||||
|
||||
// Step 3: Download the file
|
||||
string tempFile = Path.Combine(Path.GetTempPath(), $"pcsx-redux-{latestBuildId}.zip");
|
||||
|
||||
EditorUtility.DisplayProgressBar("Downloading PCSX-Redux", "Downloading...", 0.1f);
|
||||
|
||||
using (var response = await _http.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead))
|
||||
using (var client = new System.Net.WebClient())
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
long? totalBytes = response.Content.Headers.ContentLength;
|
||||
long downloadedBytes = 0;
|
||||
|
||||
using (var fileStream = File.Create(tempFile))
|
||||
using (var downloadStream = await response.Content.ReadAsStreamAsync())
|
||||
client.Headers.Add("User-Agent", "SplashEdit/1.0");
|
||||
|
||||
client.DownloadProgressChanged += (s, e) =>
|
||||
{
|
||||
byte[] buffer = new byte[81920];
|
||||
int bytesRead;
|
||||
while ((bytesRead = await downloadStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
await fileStream.WriteAsync(buffer, 0, bytesRead);
|
||||
downloadedBytes += bytesRead;
|
||||
float progress = 0.1f + 0.8f * (e.ProgressPercentage / 100f);
|
||||
string sizeMB = $"{e.BytesReceived / (1024 * 1024)}/{e.TotalBytesToReceive / (1024 * 1024)} MB";
|
||||
EditorUtility.DisplayProgressBar("Downloading PCSX-Redux", $"Downloading... {sizeMB}", progress);
|
||||
};
|
||||
|
||||
if (totalBytes.HasValue)
|
||||
{
|
||||
float progress = (float)downloadedBytes / totalBytes.Value;
|
||||
string sizeMB = $"{downloadedBytes / (1024 * 1024)}/{totalBytes.Value / (1024 * 1024)} MB";
|
||||
EditorUtility.DisplayProgressBar("Downloading PCSX-Redux",
|
||||
$"Downloading... {sizeMB}", progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
await client.DownloadFileTaskAsync(new Uri(downloadUrl), tempFile);
|
||||
}
|
||||
|
||||
log?.Invoke($"Downloaded to {tempFile}");
|
||||
@@ -144,6 +130,7 @@ namespace SplashEdit.EditorCode
|
||||
};
|
||||
var proc = Process.Start(psi);
|
||||
proc?.WaitForExit();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,6 +138,20 @@ namespace SplashEdit.EditorCode
|
||||
log?.Invoke($"Extracted to {installDir}");
|
||||
}
|
||||
|
||||
// Make executable
|
||||
|
||||
if(Application.platform == RuntimePlatform.LinuxEditor) {
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "chmod",
|
||||
Arguments = $"+x \"{SplashBuildPaths.PCSXReduxBinary}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
var proc = Process.Start(psi);
|
||||
proc?.WaitForExit();
|
||||
}
|
||||
|
||||
// Clean up temp file
|
||||
try { File.Delete(tempFile); } catch { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user