From 71362bc07916f165475edbd9e6009fd0da37c072 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 26 Jan 2025 00:22:50 +0100 Subject: [PATCH] Hotfix: API Download is decompressed --- CommonCore/SQL/src/de/steamwar/sql/NodeData.java | 10 +++++++++- WebsiteBackend/src/de/steamwar/routes/Schematic.kt | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java index 0de6c6c5..a8d7c099 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeData.java +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeData.java @@ -65,6 +65,10 @@ public class NodeData { private SchematicFormat nodeFormat; public InputStream schemData() throws IOException { + return schemData(true); + } + + public InputStream schemData(boolean decompress) throws IOException { try { return selSchemData.select(rs -> { rs.next(); @@ -73,7 +77,11 @@ public class NodeData { if(rs.wasNull() || schemData.available() == 0) { throw new SecurityException("SchemData is null"); } - return new GZIPInputStream(schemData); + if (decompress) { + return new GZIPInputStream(schemData); + } else { + return schemData; + } } catch (IOException e) { throw new SecurityException("SchemData is wrong", e); } diff --git a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt index 02f12243..1beb0f29 100644 --- a/WebsiteBackend/src/de/steamwar/routes/Schematic.kt +++ b/WebsiteBackend/src/de/steamwar/routes/Schematic.kt @@ -95,7 +95,7 @@ fun Route.configureSchematic() { } call.response.header("Content-Disposition", "attachment; filename=\"${node.name}${data.nodeFormat.fileEnding}\"") - call.respondBytes(data.schemData().readAllBytes(), contentType = ContentType.Application.OctetStream, status = HttpStatusCode.OK) + call.respondBytes(data.schemData(false).readAllBytes(), contentType = ContentType.Application.OctetStream, status = HttpStatusCode.OK) } get("/info") { val node = call.receiveSchematic() ?: return@get