Don't try to validate manifest in uploaded archives
This commit is contained in:
parent
79c01373d6
commit
ec5536e63f
1 changed files with 0 additions and 49 deletions
|
@ -103,55 +103,6 @@ namespace LANCommander.Controllers
|
|||
if (!System.IO.File.Exists(path))
|
||||
return BadRequest("Specified object does not exist");
|
||||
|
||||
try
|
||||
{
|
||||
using (ZipArchive zip = ZipFile.OpenRead(path))
|
||||
{
|
||||
var manifest = zip.Entries.FirstOrDefault(e => e.FullName == "_manifest.yml");
|
||||
|
||||
if (manifest == null)
|
||||
throw new FileNotFoundException("Manifest file not found. Add a _manifest.yml file to your archive and try again.");
|
||||
|
||||
using (StreamReader sr = new StreamReader(manifest.Open()))
|
||||
{
|
||||
manifestContents = await sr.ReadToEndAsync();
|
||||
}
|
||||
|
||||
compressedSize = zip.Entries.Sum(e => e.CompressedLength);
|
||||
uncompressedSize = zip.Entries.Sum(e => e.Length);
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException ex)
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
return BadRequest("Uploaded archive is corrupt or not a .zip file.");
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
catch
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
return BadRequest("An unknown error occurred.");
|
||||
}
|
||||
|
||||
var deserializer = new DeserializerBuilder()
|
||||
.IgnoreUnmatchedProperties()
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
|
||||
try
|
||||
{
|
||||
var manifest = deserializer.Deserialize<GameManifest>(manifestContents);
|
||||
}
|
||||
catch
|
||||
{
|
||||
System.IO.File.Delete(path);
|
||||
return BadRequest("The manifest file is invalid or corrupt.");
|
||||
}
|
||||
|
||||
var game = await GameService.Get(archive.GameId);
|
||||
|
||||
if (game == null)
|
||||
|
|
Loading…
Add table
Reference in a new issue