diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2015-01-04 20:01:49 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2015-01-04 20:01:49 +0100 |
commit | e127fa79c7d1cb6baf38c9a50125b5dc9be7bde7 (patch) | |
tree | 27a50b51ccbf5c842cf2fa60e8561623fce28855 /core/src/main | |
parent | d697fab7eb8202fceca52895dd5dee2e4f139247 (diff) | |
download | AntennaPod-e127fa79c7d1cb6baf38c9a50125b5dc9be7bde7.zip |
Trim filename if it is too long
Caused download failures on filesystems with filename limitations
fixes #579
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java | 7 |
1 files changed, 5 insertions, 2 deletions
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 { |