mirror of
https://github.com/CommonLoon102/NBloodServerSupervisor.git
synced 2025-01-20 17:14:31 +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",
|
"CPBB04.MAP",
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<string> ListableCustomMaps => Directory.GetFiles(CommandLineUtils.BloodDir,
|
private List<string> ListableCustomMaps => Directory.GetFiles(CommandLineUtils.BloodDir)
|
||||||
"*.map", SearchOption.TopDirectoryOnly)
|
|
||||||
.Select(m => Path.GetFileName(m))
|
.Select(m => Path.GetFileName(m))
|
||||||
|
.Where(m => m.ToUpper().EndsWith(".MAP"))
|
||||||
.Where(m => !ContainsString(crypticMaps, m))
|
.Where(m => !ContainsString(crypticMaps, m))
|
||||||
|
.OrderBy(m => m)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
public IList<string> ListCustomMaps() => ListableCustomMaps;
|
public IList<string> ListCustomMaps() => ListableCustomMaps;
|
||||||
@ -57,7 +58,7 @@ namespace WebInterface.Services
|
|||||||
|
|
||||||
public string StoreTempCustomMap(IFormFile formFile)
|
public string StoreTempCustomMap(IFormFile formFile)
|
||||||
{
|
{
|
||||||
string filename = Path.GetFileNameWithoutExtension(formFile.FileName);
|
string filename = Path.GetFileName(formFile.FileName);
|
||||||
ValidateFilename(filename);
|
ValidateFilename(filename);
|
||||||
|
|
||||||
string tempFolderName = Path.GetRandomFileName();
|
string tempFolderName = Path.GetRandomFileName();
|
||||||
@ -65,7 +66,7 @@ namespace WebInterface.Services
|
|||||||
if (!Directory.Exists(mapPath))
|
if (!Directory.Exists(mapPath))
|
||||||
Directory.CreateDirectory(mapPath);
|
Directory.CreateDirectory(mapPath);
|
||||||
|
|
||||||
mapPath = Path.Combine(mapPath, filename + ".map");
|
mapPath = Path.Combine(mapPath, filename);
|
||||||
FileStream fs = new FileStream(mapPath, FileMode.CreateNew);
|
FileStream fs = new FileStream(mapPath, FileMode.CreateNew);
|
||||||
formFile.CopyTo(fs);
|
formFile.CopyTo(fs);
|
||||||
|
|
||||||
@ -77,7 +78,10 @@ namespace WebInterface.Services
|
|||||||
if (string.IsNullOrWhiteSpace(filename))
|
if (string.IsNullOrWhiteSpace(filename))
|
||||||
throw new WebInterfaceException("Invalid file name.");
|
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.");
|
throw new WebInterfaceException($"You cannot play this map ({filename}) as a custom map.");
|
||||||
|
|
||||||
foreach (var chr in Path.GetInvalidFileNameChars())
|
foreach (var chr in Path.GetInvalidFileNameChars())
|
||||||
|
@ -15,6 +15,6 @@
|
|||||||
<ul>
|
<ul>
|
||||||
@foreach (var map in Model)
|
@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>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user