diff --git a/AutodlIrssi/FilterManager.pm b/AutodlIrssi/FilterManager.pm index 58e93584..afb5dfc2 100644 --- a/AutodlIrssi/FilterManager.pm +++ b/AutodlIrssi/FilterManager.pm @@ -169,6 +169,11 @@ sub checkFilter { return 0 if defined $numDownloads && $numDownloads >= $filter->{maxDownloads}; } + # Check filter size + # This is a soft check when torrentSizeInBytes is not defined, + # condition will be treated as satisfied + return checkFilterSize($ti->{torrentSizeInBytes}, $filter); + return 1; } diff --git a/AutodlIrssi/IrcHandler.pm b/AutodlIrssi/IrcHandler.pm index 9b0f0f6b..011cca85 100644 --- a/AutodlIrssi/IrcHandler.pm +++ b/AutodlIrssi/IrcHandler.pm @@ -125,7 +125,8 @@ sub onNewIrcLine { my $ti = $self->handleNewAnnouncerLine($line, $networkName, $serverName, $channelName, $userName); return 0 unless defined $ti; - my $matchedRelease = new AutodlIrssi::MatchedRelease($self->{downloadHistory}); + # Matched Release takes filterManager as argument, so that it can check filters during 2nd attempt + my $matchedRelease = new AutodlIrssi::MatchedRelease($self->{downloadHistory}, $self->{filterManager}); $matchedRelease->start($ti); return 1; } diff --git a/AutodlIrssi/MatchedRelease.pm b/AutodlIrssi/MatchedRelease.pm index d477d99d..44187c50 100644 --- a/AutodlIrssi/MatchedRelease.pm +++ b/AutodlIrssi/MatchedRelease.pm @@ -64,9 +64,10 @@ else { } sub new { - my ($class, $downloadHistory) = @_; + my ($class, $downloadHistory, $filterManager) = @_; bless { downloadHistory => $downloadHistory, + filterManager => $filterManager, }, $class; } @@ -295,6 +296,19 @@ sub _onTorrentDownloaded { if (!AutodlIrssi::FilterManager::checkFilterSize($self->{ti}{torrentSizeInBytes}, $self->{ti}{filter})) { $self->{ti}{filter}{state}->restoreDownloadCount($self->{filterDlState}); + + # Since all condition met except for torrent size + # Process the announcement again, since this time we have the torrentSizeInBytes, If a matching filter is identified, + # this block of code will not be executed again as torrent size is also part of the filter + message 4, "Because of torrent size condition processing the announcement again"; + my $ti = $self->{ti}; + + $ti->{filter} = $self->{filterManager}->findFilter($ti); + return unless defined $ti->{filter}; + + my $matchedRelease = new AutodlIrssi::MatchedRelease($self->{downloadHistory}, $self->{filterManager}); + $matchedRelease->start($ti); + return; } else {