Skip to content

Commit

Permalink
fix: handle deletion exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Apr 29, 2024
1 parent d7c93d2 commit d625547
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/GZCTF/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,22 @@ public IActionResult GetTeamTraffic([FromRoute] int challengeId, [FromRoute] int
[ProducesResponseType(typeof(RequestResponse), StatusCodes.Status404NotFound)]
public IActionResult DeleteAllTeamTraffic([FromRoute] int challengeId, [FromRoute] int partId)
{
var filePath = Path.Combine(FilePath.Capture, $"{challengeId}", $"{partId}");
try
{
var filePath = Path.Combine(FilePath.Capture, $"{challengeId}", $"{partId}");

if (!Path.Exists(filePath))
return NotFound(new RequestResponse(localizer[nameof(Resources.Program.Game_CaptureNotFound)],
StatusCodes.Status404NotFound));
if (!Path.Exists(filePath))
return NotFound(new RequestResponse(localizer[nameof(Resources.Program.Game_CaptureNotFound)],
StatusCodes.Status404NotFound));

Directory.Delete(filePath, true);
Directory.Delete(filePath, true);

return Ok();
return Ok();
}
catch (Exception e)
{
return BadRequest(new RequestResponse(e.Message));
}
}

/// <summary>
Expand Down

0 comments on commit d625547

Please sign in to comment.