From e127fa79c7d1cb6baf38c9a50125b5dc9be7bde7 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Sun, 4 Jan 2015 20:01:49 +0100 Subject: Trim filename if it is too long Caused download failures on filesystems with filename limitations fixes #579 --- .../java/de/danoeh/antennapod/core/storage/DownloadRequester.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java index 2b191c401..a94bf43d7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java @@ -378,10 +378,13 @@ public class DownloadRequester { String URLBaseFilename = URLUtil.guessFileName(media.getDownload_url(), null, media.getMime_type()); - ; - if (titleBaseFilename != "") { + if (!titleBaseFilename.equals("")) { // Append extension + final int FILENAME_MAX_LENGTH = 220; + if (titleBaseFilename.length() > FILENAME_MAX_LENGTH) { + titleBaseFilename = titleBaseFilename.substring(0, FILENAME_MAX_LENGTH); + } filename = titleBaseFilename + FilenameUtils.EXTENSION_SEPARATOR + FilenameUtils.getExtension(URLBaseFilename); } else { -- cgit v1.2.3