This file is indexed.

/usr/share/perl5/Transmission/Stats.pm is in libtransmission-client-perl 0.0804-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# ex:ts=4:sw=4:sts=4:et
package Transmission::Stats;
# See Transmission::Client for copyright statement.

=head1 NAME

Transmission::Stats - Transmission session statistics

=head1 DESCRIPTION

See "4.2 Sesion statistics" from
L<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>

=cut

use Moose;
use Transmission::Types ':all';

with 'Transmission::AttributeRole';

=head1 ATTRIBUTES

=head2 active_torrent_count

 $num = $self->active_torrent_count;

=head2 download_speed

 $num = $self->download_speed;

=head2 paused_torrent_count

 $num = $self->paused_torrent_count;

=head2 torrent_count

 $num = $self->torrent_count;

=head2 upload_speed

 $num = $self->upload_speed;

=cut

BEGIN {
    my %both = (
        activeTorrentCount  => number,
        downloadSpeed       => number,
        pausedTorrentCount  => number,
        torrentCount        => number,
        uploadSpeed         => number,
    );

    for my $camel (keys %both) {
        (my $name = $camel) =~ s/([A-Z]+)/{ "_" .lc($1) }/ge;
        __PACKAGE__->meta->add_attribute($name => (
            is => 'ro',
            isa => $both{$camel},
            coerce => 1,
            writer => "_set_$name",
            clearer => "clear_$name",
            lazy => 1,
            default => sub {
                my $self = shift;
                my $val = delete $self->_tmp_store->{$name};

                if(defined $val) {
                    return $val;
                }
                else {
                    $self->_clear_tmp_store;
                    return delete $self->_tmp_store->{$name};
                }
            },
        ));
    }

    __PACKAGE__->meta->add_attribute(_tmp_store => (
        is => 'ro',
        isa => 'HashRef',
        lazy => 1,
        builder => 'read_all',
        clearer => '_clear_tmp_store',
    ));

    __PACKAGE__->meta->add_method(read_all => sub {
        my $self = shift;
        my $lazy = $self->lazy_write;
        my(%res, $rpc);

        $rpc = $self->client->rpc('session-stats') or return;

        $self->lazy_write(1);

        for my $camel (keys %both) {
            my $name = __PACKAGE__->_camel2Normal($camel);
            my $writer = "_set_$name";
            $res{$name} = $rpc->{$camel};
            $self->$writer($rpc->{$camel});
        }

        $self->lazy_write($lazy);

        return \%res;
    });
}

=head1 LICENSE

=head1 AUTHOR

See L<Transmission::Client>

=cut

1;