Skip to content

Commit

Permalink
Fix map installation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Apr 11, 2021
1 parent 8714fe2 commit ce2ed6a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions OpenRA.Game/Map/MapPreview.cs
Expand Up @@ -485,15 +485,13 @@ public void Install(string mapRepositoryUrl, Action onSuccess)

innerData.Status = MapStatus.Downloading;
var installLocation = cache.MapLocations.FirstOrDefault(p => p.Value == MapClassification.User);
if (installLocation.Key == null || !(installLocation.Key is IReadWritePackage))
if (!(installLocation.Key is IReadWritePackage mapInstallPackage))
{
Log.Write("debug", "Map install directory not found");
innerData.Status = MapStatus.DownloadError;
return;
}

var mapInstallPackage = installLocation.Key as IReadWritePackage;

Task.Run(async () =>
{
// Request the filename from the server
Expand All @@ -517,8 +515,14 @@ void OnDownloadProgress(long total, long received, int percentage)
return;
}
response.Headers.TryGetValues("Content-Disposition", out var values);
var mapFilename = values.First().Replace("attachment; filename = ", "");
var mapFilename = response.Content.Headers.ContentDisposition?.FileName;
// Map not found
if (string.IsNullOrEmpty(mapFilename))
{
innerData.Status = MapStatus.DownloadError;
return;
}
var fileStream = new MemoryStream();
Expand Down

0 comments on commit ce2ed6a

Please sign in to comment.