Trim filename if it is too long

Caused download failures on filesystems with filename limitations

fixes #579
This commit is contained in:
daniel oeh 2015-01-04 20:01:49 +01:00
parent d697fab7eb
commit e127fa79c7
1 changed files with 5 additions and 2 deletions

View File

@ -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 {