diff --git a/backend/src/main/java/de/grimsi/gameyfin/service/FilesystemService.java b/backend/src/main/java/de/grimsi/gameyfin/service/FilesystemService.java index aa0d6e8..452f975 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/service/FilesystemService.java +++ b/backend/src/main/java/de/grimsi/gameyfin/service/FilesystemService.java @@ -98,19 +98,6 @@ public class FilesystemService { Path path = Path.of(g.getPath()); if(!path.toFile().isDirectory()) return getFilenameWithExtension(path); - - Optional optionalGameArchive; - try (Stream filesStream = Files.list(path)) { - optionalGameArchive = filesStream.filter(this::hasGameArchiveExtension).findFirst(); - } catch (IOException e) { - log.error("Error while accessing folder:", e); - throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Error while accessing folder '%s'.".formatted(path)); - } - - if(optionalGameArchive.isPresent()) { - return getFilenameWithExtension(optionalGameArchive.get()); - } - return getFilenameWithExtension(path) + ".zip"; } @@ -242,7 +229,7 @@ public class FilesystemService { Path path = Path.of(game.getPath()); if(path.toFile().isDirectory()) { - downloadFromFolder(path, outputStream); + downloadFilesAsZip(path, outputStream); } else { downloadFile(path, outputStream); } @@ -260,23 +247,6 @@ public class FilesystemService { } } - private void downloadFromFolder(Path path, OutputStream outputStream) { - Optional optionalGameArchive; - - try (Stream filesStream = Files.list(path)) { - optionalGameArchive = filesStream.filter(this::hasGameArchiveExtension).findFirst(); - } catch (IOException e) { - log.error("Error while accessing folder:", e); - throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Error while accessing folder '%s'.".formatted(path)); - } - - if(optionalGameArchive.isPresent()) { - downloadFile(optionalGameArchive.get(), outputStream); - } else { - downloadFilesAsZip(path, outputStream); - } - } - private void downloadFilesAsZip(Path path, OutputStream outputStream) { ZipOutputStream zos = new ZipOutputStream(outputStream){{ def.setLevel(Deflater.NO_COMPRESSION);