Skip to content

Commit

Permalink
0.0602 Fri Apr 29 22:18:36 CEST 2011
Browse files Browse the repository at this point in the history
       - Fix RT#67691: rpc() can now handle ids as hashes
  • Loading branch information
Jan Henning Thorsen committed Apr 29, 2011
1 parent b6af2eb commit 0626f69
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for Transmission-Client

0.0602 Fri Apr 29 22:18:36 CEST 2011
- Fix RT#67691: rpc() can now handle ids as hashes

0.0601 Wed Apr 20 12:17:43 CEST 2011
- Fix fail to load json, with json-any
http://www.cpantesters.org/cpan/report/f1e67256-36b4-11e0-afb0-adca6bb533f3
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -2,7 +2,7 @@ NAME
Transmission::Client - Interface to Transmission

VERSION
0.0601
0.0602

DESCRIPTION
Transmission::Client is the main module in a collection of modules to
Expand Down
16 changes: 13 additions & 3 deletions lib/Transmission/Client.pm
Expand Up @@ -6,7 +6,7 @@ Transmission::Client - Interface to Transmission
=head1 VERSION
0.0601
0.0602
=head1 DESCRIPTION
Expand Down Expand Up @@ -83,7 +83,7 @@ use Transmission::Torrent;
use Transmission::Session;
use constant RPC_DEBUG => $ENV{'TC_RPC_DEBUG'};

our $VERSION = eval '0.0601';
our $VERSION = eval '0.0602';
our $SESSION_ID_HEADER_NAME = 'X-Transmission-Session-Id';
my $JSON = JSON::Any->new;

Expand Down Expand Up @@ -540,7 +540,15 @@ sub rpc {

# make sure ids are numeric
if(ref $args{'ids'} eq 'ARRAY') {
$_ += 0 for(@{ $args{'ids'} });
for my $id (@{ $args{'ids'} }) {
# Need to convert string integer to "real" integer
# FLAGS = (IOK,POK,pIOK,pPOK)
# IV = 42
# ...to...
# FLAGS = (PADTMP,IOK,pIOK)
# IV = 42
$id += 0 if($id =~ /^\d+$/);
}
}

$tag = int rand 2*16 - 1;
Expand Down Expand Up @@ -614,4 +622,6 @@ Jan Henning Thorsen
=cut

no MIME::Base64;
no Moose;
1;
7 changes: 6 additions & 1 deletion t/10-client.t
Expand Up @@ -6,7 +6,7 @@ use Transmission::Client;

$SIG{'__DIE__'} = \&Carp::confess;

plan tests => 41;
plan tests => 42;

my($client, $rpc_response, $rpc_request, @torrents);
my $rpc_response_code = 409;
Expand Down Expand Up @@ -127,6 +127,11 @@ my $rpc_response_code = 409;
);
}

{ # RT#67691
$client->rpc(foo_bar => ids => [1,2,'foo']);
like($rpc_request, qr{"ids":\[1,2,"foo"\]}, 'Fix RT#67691: id "foo" is still a string');
}

TODO: {
local $TODO = 'require better testing';
ok(!$client->has_session, 'client has no session');
Expand Down

0 comments on commit 0626f69

Please sign in to comment.