Skip to content

Commit 7965612

Browse files
committed
Update ResponseValidator.php
Issue kleiram#35 I debugged the behaviour, the response from transmission rpc was fine, it was sending result object as "duplicate torrent" and argument object was empty. the validator for addtorrent was parsing it as invalid because of absence of torrent-duplicate object inside arguments. I have fixed it and requested a pull.
1 parent 08170ad commit 7965612

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/Transmission/Util/ResponseValidator.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,26 @@ public static function validateGetResponse(\stdClass $response)
5959
*/
6060
public static function validateAddResponse(\stdClass $response)
6161
{
62-
$fields = array('torrent-added', 'torrent-duplicate');
62+
// fix for issue #35
63+
if ($response -> result == 'success' &&
64+
isset ($response->arguments -> {torrent-added}) &&
65+
count($response->arguments -> {torrent-added}))
66+
{
67+
return $response->arguments -> {torrent-added};
68+
}
69+
if ($response -> result == 'duplicate torrent')
70+
return $response -> result;
71+
72+
73+
/*$fields = array('torrent-added', 'torrent-duplicate');
6374
6475
foreach ($fields as $field) {
6576
if (isset($response->arguments) &&
6677
isset($response->arguments->$field) &&
6778
count($response->arguments->$field)) {
6879
return $response->arguments->$field;
6980
}
70-
}
81+
}*/
7182

7283
throw new \RuntimeException('Invalid response received from Transmission');
7384
}

0 commit comments

Comments
 (0)