From dabf3f562ac56fba913a5e4a191e62526083b53b Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Thu, 15 Dec 2022 19:21:00 +0100 Subject: [PATCH] Fix range download (again) --- pom.xml | 4 +- .../lalafin/file/FileServeService.java | 47 +++++++++++++++++++ src/main/resources/application.yaml.example | 1 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c3e3ac4..a0b3afe 100644 --- a/pom.xml +++ b/pom.xml @@ -12,10 +12,10 @@ 11 UTF-8 UTF-8 - 2.14.2.Final + 2.15.0.Final quarkus-bom io.quarkus - 2.14.2.Final + 2.15.0.Final 2.22.1 diff --git a/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java b/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java index 0397a73..b0835b9 100644 --- a/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java +++ b/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java @@ -119,6 +119,53 @@ class FileServeInputStream extends InputStream { this.remaining = endRange + 1 - startRange; } + @Override + public int available() throws IOException { + return this.is.available(); + } + + @Override + public void close() throws IOException { + this.is.close(); + } + + @Override + public int read(byte[] buffer, int off, int len) throws IOException { + if (this.remaining == 0) { + this.is.close(); + return -1; + } else { + int read = this.is.read(buffer, off, (int) Math.min(len, this.remaining)); + this.remaining -= read; + return read; + } + } + + @Override + public byte[] readAllBytes() throws IOException { + return this.is.readAllBytes(); + } + + @Override + public byte[] readNBytes(int arg0) throws IOException { + return this.is.readNBytes(arg0); + } + + @Override + public int readNBytes(byte[] arg0, int arg1, int arg2) throws IOException { + return this.is.readNBytes(arg0, arg1, arg2); + } + + @Override + public long skip(long arg0) throws IOException { + return this.is.skip(arg0); + } + + @Override + public void skipNBytes(long arg0) throws IOException { + this.is.skipNBytes(arg0); + } + @Override public int read(byte[] buffer) throws IOException { if (this.remaining == 0) { diff --git a/src/main/resources/application.yaml.example b/src/main/resources/application.yaml.example index 45a84ac..111b37d 100644 --- a/src/main/resources/application.yaml.example +++ b/src/main/resources/application.yaml.example @@ -10,6 +10,7 @@ quarkus: native: container-build: true container-runtime: docker + builder-image: quay.io/quarkus/ubi-quarkus-mandrel:22.3-java17 enable-all-security-services: true enable-https-url-handler: true