Commit a3877dd5 authored by Luc Didry's avatar Luc Didry

Add a lockfile to GSB database update to prevent concurrent updates

parent 0d21e43d
Pipeline #97082 passed with stages
in 7 minutes and 46 seconds
......@@ -2,6 +2,9 @@ Revision history for Perl application Lstu
0.22-0 ????-??-??
0.21-4 2018-12-17
- Add a lockfile to GSB database update to prevent concurrent updates
0.21-3 2018-11-19
- Fix Pg sessions and urls delete fonctions
......
requires 'inc::Module::Install::DSL';
requires 'Mojolicious', '>= 7.33';
requires 'Mojolicious', '>= 8.09';
requires 'Data::Validate::URI';
requires 'Net::Domain::TLD', '>= 1.74';
requires 'Mojolicious::Plugin::I18N';
......
This diff is collapsed.
......@@ -221,12 +221,19 @@ sub _gsb {
storage => Net::Google::SafeBrowsing4::Storage::File->new(path => Mojo::File->new($Bin, '..' , 'safebrowsing_db')),
);
my $lock_file = Mojo::File->new($Bin, '..', 'gsb.lock');
if ($force_update) {
$lock_file->touch;
$gsb->update();
$lock_file->remove_tree;
} elsif ($check) {
my $update = Mojo::File->new($Bin, '..' , 'safebrowsing_db')->to_string;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($update);
$gsb->update() if $mtime < time - 86400;
if (! -e $lock_file->to_string) {
$lock_file->touch;
my $update = Mojo::File->new($Bin, '..' , 'safebrowsing_db')->to_string;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($update);
$gsb->update() if $mtime < time - 86400;
$lock_file->remove_tree;
}
}
return $gsb;
......
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