diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-12 15:48:00 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-12 15:48:00 -0700 |
commit | f14c1fe6c7484a1d83ef2078ccc6abfd28eb545b (patch) | |
tree | 7a2f9125274469633e7457241b1061c93023cb11 /app/src/main/java | |
parent | 981a0c6ab6bc9b7da67cf60076064f291a39de49 (diff) | |
download | dsub-f14c1fe6c7484a1d83ef2078ccc6abfd28eb545b.tar.gz dsub-f14c1fe6c7484a1d83ef2078ccc6abfd28eb545b.tar.bz2 dsub-f14c1fe6c7484a1d83ef2078ccc6abfd28eb545b.zip |
#519 Truncate file past size limit instead of just failing
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/FileUtil.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/FileUtil.java b/app/src/main/java/github/daneren2005/dsub/util/FileUtil.java index 332f775c..31d7e31d 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/FileUtil.java +++ b/app/src/main/java/github/daneren2005/dsub/util/FileUtil.java @@ -70,6 +70,7 @@ public class FileUtil { private static final List<String> MUSIC_FILE_EXTENSIONS = Arrays.asList("mp3", "ogg", "aac", "flac", "m4a", "wav", "wma"); private static final List<String> VIDEO_FILE_EXTENSIONS = Arrays.asList("flv", "mp4", "m4v", "wmv", "avi", "mov", "mpg", "mkv"); private static final List<String> PLAYLIST_FILE_EXTENSIONS = Arrays.asList("m3u"); + private static final int MAX_FILENAME_LENGTH = 254 - ".complete.mp3".length(); private static File DEFAULT_MUSIC_DIR; private static final Kryo kryo = new Kryo(); private static HashMap<String, MusicDirectory.Entry> entryLookup; @@ -123,8 +124,12 @@ public class FileUtil { fileName.append(track).append("-"); } - fileName.append(fileSystemSafe(song.getTitle())).append("."); + fileName.append(fileSystemSafe(song.getTitle())); + if(fileName.length() >= MAX_FILENAME_LENGTH) { + fileName.setLength(MAX_FILENAME_LENGTH); + } + fileName.append("."); if(song.isVideo()) { String videoPlayerType = Util.getVideoPlayerType(context); if("hls".equals(videoPlayerType)) { |