Subject: | ignore/watch do not update _watching hash when first command after disconnect |
There is a bug with both the ignore and watch commands not deleting or adding the tube in the _watching() hash when run as the first command after the disconnect. The server list of tubes watched is correct, but another reconnect will restore the wrong list.
The reason is that connect() happens in _interact after $watching is saved. That calls list_tubes_watched() to update the _watching list from server so it can restore the watch list. That changes the hash in _watching and breaks the alias in $watching so the delete/add don't change the saved list.
This should exercise the problem:
$client->watch("foo");
$client->watch("bar");
$client->disconnect();
$client->ignore("foo");
ok(exists $client->_watching()->{"foo"})
The workaround is to call connect() before calling ignore/watch.
The fix is probably to do the "delete" and add directly to _watching:
delete $self-_watching()->{$tube};
$self->_watching()->{$tube}++;