Skip to content

Commit

Permalink
prevents sticker race conditions from crashing the server (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Mar 3, 2012
1 parent c6c8a3c commit cb3cd12
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/daemon.coffee
Expand Up @@ -173,8 +173,12 @@ updateStickers = ->
if name == "file"
current_file = value
else if name == "sticker"
[_, value] = mpd.split_once value, "="
my_mpd.library.track_table[current_file].last_queued = new Date(value)
value = mpd.split_once(value, "=")[1]
track = my_mpd.library.track_table[current_file]
if track?
track.last_queued = new Date(value)
else
log.error "#{current_file} has a last-queued sticker of #{value} but we don't have it in our library cache."

getRandomSongFiles = (count) ->
return [] if count == 0
Expand Down Expand Up @@ -243,7 +247,7 @@ class DirectMpd extends mpd.Mpd
constructor: (@mpd_socket) ->
super()
@mpd_socket.on 'data', (data) =>
@receive data.toString()
@receive data
@mpd_socket.on 'end', ->
log.warn "server mpd disconnect"
@mpd_socket.on 'error', ->
Expand Down

0 comments on commit cb3cd12

Please sign in to comment.