Skip to content

Commit

Permalink
check for null in updateNowPlayingFile, oops.
Browse files Browse the repository at this point in the history
fixes #35 and #33
  • Loading branch information
Hyphen-ated committed Jul 5, 2015
1 parent 43e340a commit e337bbb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/hyphenated/djbot/DjService.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,16 @@ private void updatePlayedSongsFile() throws IOException {

//go write to the filesystem so the user can overlay this text file on their stream if they want
private void updateNowPlayingFile(SongEntry currentSong) {
String nowPlaying = conf.getNowPlayingPattern();
nowPlaying = nowPlaying.replace("%title%", currentSong.getTitle());
nowPlaying = nowPlaying.replace("%user%", currentSong.getUser());
nowPlaying = nowPlaying.replace("%length%", currentSong.buildDurationStr());
String nowPlaying;
if(currentSong != null) {
nowPlaying = conf.getNowPlayingPattern();
nowPlaying = nowPlaying.replace("%title%", currentSong.getTitle());
nowPlaying = nowPlaying.replace("%user%", currentSong.getUser());
nowPlaying = nowPlaying.replace("%length%", currentSong.buildDurationStr());
} else {
nowPlaying = "";
}

try {
FileUtils.writeStringToFile(new File(nowPlayingFilePath), nowPlaying, false);
} catch (IOException e) {
Expand Down

0 comments on commit e337bbb

Please sign in to comment.