Skip to content

Commit

Permalink
Merge #3899 Fix archive.org fallback URLs for versions with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 1, 2023
2 parents e76f030 + bcae424 commit 3ef0a29
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Mod list fixes and improvements (#3883 by: HebaruSan; reviewed: techman83)
- [Multiple] Multi-game labels (#3885 by: HebaruSan; reviewed: techman83)
- [Multiple] Alternate mod dirs for validation and manual installs (#3891 by: HebaruSan; reviewed: techman83)
- [Core] Fix archive.org fallback URLs for versions with spaces (#3899 by: HebaruSan)

### Internal

Expand Down
8 changes: 4 additions & 4 deletions Core/Net/NetFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public string GetInProgressFileName(Uri url, string description)

public string GetInProgressFileName(List<Uri> urls, string description)
{
var filenames = urls.Select(url => GetInProgressFileName(NetFileCache.CreateURLHash(url), description))
.ToArray();
return filenames.FirstOrDefault(filename => File.Exists(filename))
?? filenames.FirstOrDefault();
var filenames = urls?.Select(url => GetInProgressFileName(NetFileCache.CreateURLHash(url), description))
.ToArray();
return filenames?.FirstOrDefault(filename => File.Exists(filename))
?? filenames?.FirstOrDefault();
}

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion Core/Net/NetModuleCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public void CheckFreeSpace(long bytesToStore)
}

public string GetInProgressFileName(CkanModule m)
=> cache.GetInProgressFileName(m.download, m.StandardName());
=> m.download == null
? null
: cache.GetInProgressFileName(m.download, m.StandardName());

private static string DescribeUncachedAvailability(CkanModule m, FileInfo fi)
=> fi.Exists
Expand Down
2 changes: 1 addition & 1 deletion Core/Types/CkanModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public Uri InternetArchiveDownload
{
get
{
string verStr = version.ToString().Replace(':', '-');
string verStr = version.ToString().Replace(' ', '_').Replace(':', '-');
// Some alternate registry repositories don't set download_hash
return (download_hash?.sha1 != null && license.All(l => l.Redistributable))
? new Uri(
Expand Down

0 comments on commit 3ef0a29

Please sign in to comment.