From af93f1eed11d4de634eefb25b7bdb5a290f6aacd Mon Sep 17 00:00:00 2001 From: Benz0X Date: Sat, 8 Dec 2018 15:10:12 +0100 Subject: [PATCH] Correct corrupted downloaded zip Prevent the zipping of twice the same file (resulting in an error and a corrupted zip on Linux) when the cover is embedded in tags --- .../airsonic/player/controller/DownloadController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/DownloadController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/DownloadController.java index d21309d4..e39c7878 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/DownloadController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/DownloadController.java @@ -207,6 +207,8 @@ public class DownloadController implements LastModified { * @param zipFileName The name of the resulting zip file. @throws IOException If an I/O error occurs. */ private void downloadFiles(HttpServletResponse response, TransferStatus status, List files, int[] indexes, File coverArtFile, HttpRange range, String zipFileName) throws IOException { + boolean cover_embedded = false; + if (indexes != null && indexes.length == 1) { downloadFile(response, status, files.get(indexes[0]).getFile(), range); return; @@ -232,8 +234,13 @@ public class DownloadController implements LastModified { for (MediaFile mediaFile : filesToDownload) { zip(out, mediaFile.getParentFile(), mediaFile.getFile(), status, range); + if (coverArtFile != null && coverArtFile.exists()) { + if (mediaFile.getFile().getCanonicalPath() == coverArtFile.getCanonicalPath()) { + cover_embedded = true; + } + } } - if (coverArtFile != null && coverArtFile.exists()) { + if (coverArtFile != null && coverArtFile.exists() && cover_embedded == false) { zip(out, coverArtFile.getParentFile(), coverArtFile, status, range); }