Net-DirectConnect
view release on metacpan or search on metacpan
lib/Net/DirectConnect/filelist.pm view on Meta::CPAN
'<', $self->{filelist_scan}
);
return
if -e $self->{files}
and -s $self->{files} > 200
and $self->{filelist_scan} > time - $^T + 86400 * -M $self->{files};
#$self->log( 'starter==','$0=',$0, $INC{'Net/DirectConnect/filelist.pm'}, $^X, 'share=', @{ $self->{'share'} } );
#$0 !~ m{(.*\W)?share.pl$}
!$self->{'filelist_fork'}
? $self->filelist_make()
: $self->{'filelist_builder'} ? psmisc::start $self->{'filelist_builder'}, @{ $self->{'share'} } : psmisc::start $^X,
$INC{'Net/DirectConnect/filelist.pm'}, @{ $self->{'share'} };
#: psmisc::startme( 'filelist', grep { -d } @ARGV );
},
$self
) if $self->{filelist_scan};
#Net::DirectConnect::
psmisc::schedule(
#10, #dev! 300!
$self->{filelist_reload},
#our $filelist_load_sub__ ||=
sub {
my $self = shift;
#psmisc::startme( 'filelist', grep { -d } @ARGV );
#my($sharesize,$sharefiles) =
$self->filelist_load(
#sub {
#my ( $sharesize, $sharefiles ) = @_;
#$dc->{INF}{SS} = $sharesize, $dc->{INF}{SF} = $sharefiles, $dc->{sharesize} = $sharesize, if $sharesize;
##todo! change INF cmd or myinfo
#}
);
},
$self
) if $self->{filelist_scan};
},
#psmisc::startme( 'filelist', grep { -d } @ARGV ) if !-e $config{files} or !-e $config{files}.'.bz2';
$self->{handler_int}{file_recieved} = sub {
my $self = shift if ref $_[0];
my ( $full, $filename ) = @_;
#$self->{'file_recv_tth'} =
my ($tth) = $filename =~ m{^TTH/(\w+)};
=z
return unless $tth;
$self->{share_full}{$tth} = $as;
my ($name) = $as =~ m{^([^/\\]+)$};
return unless $name;
$self->{share_full}{$tth} = $full_local, $self->{share_tth}{$full_local} = $tth, $self->{share_tth}{$file} = $tth,
if $tth;
$self->{share_full}{$file} ||= $full_local;
=cut
$self->log( 'dev', 'adding downloaded file to share', $full, $tth ),
$self->share_add_file( $full, $tth ), $self->share_changed()
if !$self->{'file_recv_filelist'} and !$self->{'no_auto_share_downloaded'}; # unless $self->{'no_auto_share_downloaded'};
#TODO $self->{db}->insert_hash( 'filelist', $f ) if !$self->{no_sql} and $f->{tth};
;
};
$self->filelist_load() unless $standalone; # (caller)[0] ~~ __PACKAGE__;
#$self->log('initok');
return $self;
}
eval q{ #do
use lib '../..';
use Net::DirectConnect;
print "making\n";
__PACKAGE__->new(@ARGV)->{db}->upgrade(), exit if $ARGV[0] eq 'upgrade';
__PACKAGE__->new(@ARGV)->filelist_make(@ARGV),;
}, print $@ unless caller;
1;
( run in 1.853 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )