mirror of
https://github.com/CommonLoon102/NBloodServerSupervisor.git
synced 2025-01-03 08:32:45 +01:00
custom map name fixes (#11)
* attempt to fix linux file load * fix download links and sort map names
This commit is contained in:
parent
7ff8ad8407
commit
2ca894266c
@ -29,10 +29,11 @@ namespace WebInterface.Services
|
||||
"CPBB04.MAP",
|
||||
};
|
||||
|
||||
private List<string> ListableCustomMaps => Directory.GetFiles(CommandLineUtils.BloodDir,
|
||||
"*.map", SearchOption.TopDirectoryOnly)
|
||||
private List<string> ListableCustomMaps => Directory.GetFiles(CommandLineUtils.BloodDir)
|
||||
.Select(m => Path.GetFileName(m))
|
||||
.Where(m => m.ToUpper().EndsWith(".MAP"))
|
||||
.Where(m => !ContainsString(crypticMaps, m))
|
||||
.OrderBy(m => m)
|
||||
.ToList();
|
||||
|
||||
public IList<string> ListCustomMaps() => ListableCustomMaps;
|
||||
@ -57,7 +58,7 @@ namespace WebInterface.Services
|
||||
|
||||
public string StoreTempCustomMap(IFormFile formFile)
|
||||
{
|
||||
string filename = Path.GetFileNameWithoutExtension(formFile.FileName);
|
||||
string filename = Path.GetFileName(formFile.FileName);
|
||||
ValidateFilename(filename);
|
||||
|
||||
string tempFolderName = Path.GetRandomFileName();
|
||||
@ -65,7 +66,7 @@ namespace WebInterface.Services
|
||||
if (!Directory.Exists(mapPath))
|
||||
Directory.CreateDirectory(mapPath);
|
||||
|
||||
mapPath = Path.Combine(mapPath, filename + ".map");
|
||||
mapPath = Path.Combine(mapPath, filename);
|
||||
FileStream fs = new FileStream(mapPath, FileMode.CreateNew);
|
||||
formFile.CopyTo(fs);
|
||||
|
||||
@ -77,7 +78,10 @@ namespace WebInterface.Services
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
throw new WebInterfaceException("Invalid file name.");
|
||||
|
||||
if (ContainsString(crypticMaps, filename + ".map"))
|
||||
if (!filename.ToUpper().EndsWith(".MAP"))
|
||||
throw new WebInterfaceException("Invalid extension.");
|
||||
|
||||
if (ContainsString(crypticMaps, filename))
|
||||
throw new WebInterfaceException($"You cannot play this map ({filename}) as a custom map.");
|
||||
|
||||
foreach (var chr in Path.GetInvalidFileNameChars())
|
||||
|
@ -15,6 +15,6 @@
|
||||
<ul>
|
||||
@foreach (var map in Model)
|
||||
{
|
||||
<li><a href="@Url.Link("DownloadCustomMap", new { map = map })">@map</a></li>
|
||||
<li><a href="@Url.Action("Index", "CustomMaps", new { map = map })">@map</a></li>
|
||||
}
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user