when someone calls for it, they rely that after the call to ->update_db
returns the database is fresh
there are tree callers - 'single', 'one-shot' and the database update
notification
$self->connect_mpd;
$self->connect_db;
$self->connect_mpd;
$self->connect_db;
- $mpd->send('listallinfo')->on_done(
- sub {
- try {
- my $rows = shift;
- $db->begin_work;
+ my $rows = $mpd->send('listallinfo')->get;
+ try {
+ $db->begin_work;
- foreach my $entry (@$rows) {
- next unless exists $entry->{file};
- $self->db_store_song( $entry->{file},
- $entry->{Artist}, $entry->{Album} );
- $song_count++;
- }
+ foreach my $entry (@$rows) {
+ next unless exists $entry->{file};
+ $self->db_store_song( $entry->{file},
+ $entry->{Artist}, $entry->{Album} );
+ $song_count++;
+ }
- $log->info("Updated data about $song_count songs");
+ $log->info("Updated data about $song_count songs");
- $self->db_remove_stale_entries;
+ $self->db_remove_stale_entries;
- $self->db_set_option( generation => $db_generation );
+ $self->db_set_option( generation => $db_generation );
- $db->commit;
- }
- catch {
- my $err = $@;
+ $db->commit;
+ }
+ catch {
+ my $err = $@;
}
method db_find_suitable_songs($num) {
}
method db_find_suitable_songs($num) {