archseer/ruby-mpd

No event generated when 'updating_db' disappears from 'status'

devyn opened this issue · 2 comments

Ideally, if I

@mpd.on :updating_db do |job_id|
  puts "Updating DB #{job_id.inspect}"
end
@mpd.update

I should get something like

Updating DB 1
Updating DB nil

so that I can tell when the update has ended, but that doesn't happen at all. Instead the callback is only executed when updating_db appears.

Here's the relevant status change:

{:volume=>96, :repeat=>false, :random=>false, :single=>false, :consume=>false, :playlist=>5002, :playlistlength=>4999, :mixrampdb=>0.0, :state=>:play, :song=>0, :songid=>5000, :time=>[5, 244], :elapsed=>4.574, :bitrate=>1202, :audio=>[44100, 16, 2], :updating_db=>1, :nextsong=>1, :nextsongid=>5001}
{:volume=>96, :repeat=>false, :random=>false, :single=>false, :consume=>false, :playlist=>5002, :playlistlength=>4999, :mixrampdb=>0.0, :state=>:play, :song=>0, :songid=>5000, :time=>[6, 244], :elapsed=>5.619, :bitrate=>1224, :audio=>[44100, 16, 2], :nextsong=>1, :nextsongid=>5001}

As you can see, updating_db simply disappears when the update has completed, which is fine, but I should also get an event.

Hmm, I see. The way the event logic works is that we iterate over the keys of the new status, and compare them to the old status: https://github.com/archSeer/ruby-mpd/blob/master/lib/ruby-mpd.rb#L113-L116

So when the new event doesn't contain the updating_db ID, that key gets skipped over. We should probably first aggregate the keys from both the old and new status, then iterate over them. I'll try to get to it later today.

Thanks!

On Mon, Apr 21, 2014 at 2:33 AM, Blaž Hrastnik notifications@github.comwrote:

Closed #18 #18 via af35d7chttps://github.com/archSeer/ruby-mpd/commit/af35d7c97d56daa326757e51edd6caaead154dcd
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/18
.

~devyn