diff --git a/ChangeLog b/ChangeLog index 48fc4c1..79e9dc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-11-18 Michael Herstine + + Bugfix for issue #1. + 2020-10-22 Michael Herstine Preparing for publication to crates.io. diff --git a/NEWS b/NEWS index 813fb32..d3eb90f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ mpdpopm News -- history of user-visible changes -*- outline -*- +* 0.1.13 build + +** Bugfixes + +*** Issue 1: `get_messages` fails on repeated channels * 0.1.12 build Minor changes preparatory to publication on crates.io; no user-facing changes. diff --git a/README.org b/README.org index 86820b7..bd0f465 100644 --- a/README.org +++ b/README.org @@ -2,7 +2,7 @@ #+DESCRIPTION: mpdpopm #+AUTHOR: Michael Herstine #+EMAIL: sp1ff@pobox.com -#+DATE: <2020-10-22 Thu 09:33> +#+DATE: <2020-11-18 Wed 12:53> #+AUTODATE: t * Introduction @@ -16,11 +16,11 @@ * Installing -While I plan on publishing this to [[https://crates.io/][crates.io]], I have not yet done so. You can get a source tarball & install it through the usual =configure && make && make install=: +mpdpopm is [[https://crates.io/crates/mpdpopm][available]] on [[https://crates.io/][crates.io]], but you can also get a source tarball & install it through the usual =configure && make && make install=: #+BEGIN_SRC bash -curl -L -O https://github.com/mpdpopm/archive/0.1.12.tar.gz -tar xf mpdpopm-0.1.12.tar.gz && cd mpdpopm-0.1.12 +curl -L -O https://github.com/mpdpopm/archive/0.1.13.tar.gz +tar xf mpdpopm-0.1.13.tar.gz && cd mpdpopm-0.1.13 ./configure && make all check sudo make install #+END_SRC diff --git a/configure.ac b/configure.ac index a7d3d3c..c2284a4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mpdpopm], [0.1.12], [sp1ff@pobox.com], [mpdpopm], [https://github.com/sp1ff/mpdpopm]) +AC_INIT([mpdpopm], [0.1.13], [sp1ff@pobox.com], [mpdpopm], [https://github.com/sp1ff/mpdpopm]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([mpdpopm/Cargo.toml.in]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability -Wno-override gnits std-options dist-bzip2 dist-xz]) diff --git a/mpdpopm/src/clients.rs b/mpdpopm/src/clients.rs index 9092aa0..dd72310 100644 --- a/mpdpopm/src/clients.rs +++ b/mpdpopm/src/clients.rs @@ -1105,11 +1105,21 @@ impl IdleClient { if line.starts_with("message: ") { msgs.push(String::from(&line[9..])); } else if line.starts_with("channel: ") { - m.insert(chan.clone(), msgs.clone()); + match m.get_mut(&chan) { + Some(v) => v.append(&mut msgs), + None => { + m.insert(chan.clone(), msgs.clone()); + } + } chan = String::from(&line[9..]); msgs = Vec::new(); } else if line == "OK" { - m.insert(chan.clone(), msgs.clone()); + match m.get_mut(&chan) { + Some(v) => v.append(&mut msgs), + None => { + m.insert(chan.clone(), msgs.clone()); + } + } state = State::Finished; } else { return Err(Error::GetMessages { @@ -1167,4 +1177,22 @@ OK let val = hm.get("send-to-playlist").unwrap(); assert!(val.len() == 1); } + + /// Test issue #1 + #[tokio::test] + async fn test_issue_1() { + let mock = Box::new(Mock::new(&[( + "readmessages", + "channel: playcounts +message: a +channel: playcounts +message: b +OK +", + )])); + let mut cli = IdleClient::new(mock).unwrap(); + let hm = cli.get_messages().await.unwrap(); + let val = hm.get("playcounts").unwrap(); + assert_eq!(val.len(), 2); + } }