I'm a bit excited and scared to ask this, but can I get co-maint for ORLite::Mirror?
------- Forwarded message ------- From: "Cosimo Streppone" <cos...@streppone.it> To: "Adam Kennedy" <ad...@cpan.org> Subject: ORLite::Mirror fix to avoid online check startup penalty Date: Mon, 12 Mar 2012 17:49:32 +0100 Hi Adam, Did you have time to look at the patch I sent you? Can I find you somewhere on IRC? ------- Forwarded message ------- From: "Cosimo Streppone" <cos...@streppone.it> To: "Adam Kennedy" <ad...@cpan.org> Subject: ORLite::Mirror fix to avoid online check startup penalty Date: Fri, 09 Mar 2012 18:03:33 +0100 Hi Adam, I worked on a fix for ORLite::Mirror. I tried committing to svn.ali.as (I'm CPAN ID COSIMO) but no joy, so here's the inline patch. It avoids the startup online check penalty if you have an up-to-date local mirror of the db. I tried to not break anything :) Works wonderfully for me. Cheers, ------------8<------------------------------------------------- Index: lib/ORLite/Mirror.pm =================================================================== --- lib/ORLite/Mirror.pm (revision 15285) +++ lib/ORLite/Mirror.pm (working copy) @@ -127,13 +127,6 @@ $class->prune($path) if $params{prune}; } - # Are we online (fake to true if the URL is local) - my $online = !! ( $url =~ /^file:/ or LWP::Online::online() ); - unless ( $online or -f $path or $stub ) { - # Don't have the file and can't get it - Carp::croak("Cannot fetch database without an internet connection"); - } - # If the file doesn't exist, sync at compile time. my $STUBBED = 0; unless ( -f $db ) { @@ -154,7 +147,15 @@ # Don't update if the file is newer than the maxage my $mtime = (stat($path))[9] || 0; my $old = (time - $mtime) > $maxage; - if ( not $STUBBED and -f $path ? ($old and $online) : 1 ) { + if ( not $STUBBED and -f $path ? $old : 1 ) { + + # Are we online (fake to true if the URL is local) + my $online = !! ( $url =~ /^file:/ or LWP::Online::online() ); + unless ( $online or -f $path or $stub ) { + # Don't have the file and can't get it + Carp::croak("Cannot fetch database without an internet connection"); + } + # Create the default useragent my $useragent = delete $params{useragent}; unless ( $useragent ) { Index: Changes =================================================================== --- Changes (revision 15285) +++ Changes (working copy) @@ -2,6 +2,8 @@ 1.24 to be released - Move decompression modules to require to save 2-3 meg of memory + - Avoid online check startup penalty if we have an up-to-date + cached copy of the remote database. 1.23 Fri 3 Feb 2012 - Updating Module::Install::DSL to 1.04 ------------8<------------------------------------------------- -- Cosimo