Verified Commit 4388fad9 authored by Luc Didry's avatar Luc Didry

Fix URL removal in memcached from safebrowsingcheck command

parent 7ebf488e
Pipeline #82985 passed with stages
in 9 minutes and 48 seconds
Revision history for Perl application Lstu
0.21-1 2018-10-17
- Fix URL removal in memcached from safebrowsingcheck command
0.21-0 2018-10-17
- Allow to delete URLs and ban IPs from safebrowsingcheck
- Add ban CLI tool for banning and unbanning IP addresses
......
......@@ -51,17 +51,6 @@ sub run {
}
});
if (scalar(@{$config->{memcached_servers}})) {
$c->app->plugin(CHI => {
lstu_urls_cache => {
driver => 'Memcached',
servers => $config->{memcached_servers},
expires_in => '1 day',
expires_on_backend => 1,
}
});
}
getopt \@args,
'info=s{1,}' => \my @info,
'r|remove=s{1,}' => \my @remove,
......@@ -93,9 +82,6 @@ sub run {
}
if ($confirm =~ m/^y(es)?$/i) {
if ($u->delete) {
if (scalar(@{$config->{memcached_servers}})) {
$c->app->chi('lstu_urls_cache')->remove($e);
}
say sprintf('Success: %s URL has been removed', $e);
} else {
say sprintf('Failure: %s URL has not been removed', $e);
......
......@@ -173,7 +173,11 @@ sub delete {
# We found the URL, it hasn't been deleted
return 0;
} else {
if (scalar(@{$c->app->config('memcached_servers')})) {
$c->app->chi('lstu_urls_cache')->remove($c->short);
}
$c = Lstu::DB::URL->new(app => $c->app);
# We didn't found the URL, it has been deleted
return 1;
}
......
......@@ -67,6 +67,18 @@ sub startup {
# Helpers
$self->plugin('Lstu::Plugin::Helpers');
# URL cache
if (scalar(@{$config->{memcached_servers}})) {
$self->plugin(CHI => {
lstu_urls_cache => {
driver => 'Memcached',
servers => $config->{memcached_servers},
expires_in => '1 day',
expires_on_backend => 1,
}
});
}
$self->plugin('Mount' => {$config->{prefix} => File::Spec->catfile($Bin, '..', 'script', 'application')});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment