Feed archive info into the HTTP downloader so we get proper downloader progress bars.

This commit is contained in:
Timothy Baldridge 2019-11-07 22:19:39 -07:00
parent 2fb857a093
commit 6996556642
3 changed files with 11 additions and 6 deletions

View File

@ -105,7 +105,7 @@ namespace Wabbajack.Lib.Downloaders
if (!download)
return true;
var header_var = "1";
var header_var = a.Size == 0 ? "1" : a.Size.ToString();
if (response.Content.Headers.Contains("Content-Length"))
header_var = response.Content.Headers.GetValues("Content-Length").FirstOrDefault();

View File

@ -38,7 +38,10 @@ namespace Wabbajack.UI
string dest = Path.Combine(Consts.ModListDownloadFolder, SelectedModList.Links.MachineURL + ExtensionManager.Extension);
var window = new DownloadWindow(SelectedModList.Links.Download, SelectedModList.Title, dest);
var window = new DownloadWindow(SelectedModList.Links.Download,
SelectedModList.Title,
SelectedModList.Links.DownloadMetadata?.Size ?? 0,
dest);
window.ShowDialog();
if (window.Result == DownloadWindow.WindowResult.Completed)

View File

@ -34,10 +34,10 @@ namespace Wabbajack.UI
public WindowResult Result { get; internal set; } = WindowResult.Undefined;
public DownloadWindow(string url, string name, string destination)
public DownloadWindow(string url, string name, long size, string destination)
{
InitializeComponent();
DataContext = new DownloadWindowViewModel(this, url, name, destination);
DataContext = new DownloadWindowViewModel(this, url, name, size, destination);
}
}
@ -46,13 +46,15 @@ namespace Wabbajack.UI
private readonly string _destination;
private readonly DownloadWindow _parent;
private long _size;
public DownloadWindowViewModel(DownloadWindow parent, string url, string name, string destination)
public DownloadWindowViewModel(DownloadWindow parent, string url, string name, long size, string destination)
{
_parent = parent;
_url = url;
_downloadName = name;
_destination = destination;
_size = size;
Start();
}
@ -64,7 +66,7 @@ namespace Wabbajack.UI
WorkQueue.CustomReportFn = (progress, msg) => { DownloadProgress = progress; };
var state = DownloadDispatcher.ResolveArchive(_url);
state.Download(new Archive {Name = _downloadName}, _destination);
state.Download(new Archive {Name = _downloadName, Size = _size}, _destination);
_destination.FileHash();