From f447520c747c3c7a1b90232e644a917b984427e0 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 29 Feb 2024 09:06:54 +0000 Subject: Use encoded path for storage --- MatrixMediaGate/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'MatrixMediaGate') diff --git a/MatrixMediaGate/Program.cs b/MatrixMediaGate/Program.cs index 19ae4f8..e254413 100644 --- a/MatrixMediaGate/Program.cs +++ b/MatrixMediaGate/Program.cs @@ -126,7 +126,9 @@ var jsonOptions = new JsonSerializerOptions { // We dump failed requests to disk async Task ProxyDump(ProxyConfiguration cfg, HttpContext ctx, HttpRequestMessage? req, HttpResponseMessage? resp, Exception? e) { if (ctx.Response.StatusCode >= 400 && cfg.DumpFailedRequests) { - var path = Path.Combine(cfg.DumpPath, "failed_requests", $"{resp.StatusCode}-{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}-{ctx.Request.Path}.json"); + var dir = Path.Combine(cfg.DumpPath, "failed_requests"); + Directory.CreateDirectory(dir); + var path = Path.Combine(cfg.DumpPath, "failed_requests", $"{resp.StatusCode}-{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}-{ctx.Request.GetEncodedPathAndQuery()}.json"); await using var file = File.Create(path); await JsonSerializer.SerializeAsync(file, new { Self = new { -- cgit 1.5.1