bagder: curl-www/dl remcheck.pl,1.3,1.4

[email protected]
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/dl
In directory labb:/tmp/cvs-serv16006

Modified Files:
	remcheck.pl 
Log Message:
more summary, URL content cache


Index: remcheck.pl
===================================================================
RCS file: /cvsroot/curl/curl-www/dl/remcheck.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- remcheck.pl	10 May 2005 08:43:44 -0000	1.3
+++ remcheck.pl	10 May 2005 09:31:12 -0000	1.4
@@ -11,8 +11,8 @@
 
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
     gmtime(time);
-my $logfile = sprintf("log/remcheck-%04d%02d%02d-%02d%02d.log",
-                      $year+1900, $mon, $mday, $hour, $min);
+my $logfile = sprintf("log/remcheck-%04d%02d%02d-%02d%02d%02d.log",
+                      $year+1900, $mon+1, $mday, $hour, $min, $sec);
 
 # open and close each time to allow removal at any time
 sub logmsg {
@@ -73,10 +73,29 @@
 
 #print getlast5versions();
 
-my $curlcmd="curl -fsm20 --compressed";
+# a hash with arrays (url => url contents)
+my %urlhash;
+sub geturl {
+    my $curlcmd="curl -fsm20 --compressed";
 
-my $update;
-my $missing;
+    my ($url) = @_;
+
+    if($urlhash{$url}) {
+        # return the array
+        logmsg " URL contents CACHED, no need to fetch again\n";
+        return @{$urlhash{$url}};
+    }
+    my @content = `$curlcmd \"$url\"`;
+    if(@content) {
+        # store the content in the hash
+        @{$urlhash{$url}}=@content;
+    }
+    return @content;
+}
+
+my $update=0;
+my $uptodate=0;
+my $missing=0;
 my $ref;
 for $ref (@all) {
     my $inurl = $$ref{'churl'};
@@ -114,7 +133,7 @@
         $churl =~ s/\$osversion/$osversion/g;
 
         logmsg " Used URL: \"$churl\"\n";
-        my @data = `$curlcmd "$churl"`;
+        my @data = geturl($churl);
 
         if($chregex) {
             if(!$data[0]) {
@@ -154,6 +173,7 @@
                         $update++;
                     }
                     else {
+                        $uptodate++;
                         logmsg " NOT updated\n";
                     }
                     last;
@@ -182,7 +202,7 @@
                     $churl =~ s/\$osversion/$osversion/g;
                     
                     logmsg " Retry with version $ver: \"$churl\"\n";
-                    my @data = `$curlcmd "$churl"`;
+                    my @data = geturl($churl);
                 }
             }
 
@@ -199,6 +219,7 @@
                 $update++;
             }
             else {
+                $uptodate++;
                 logmsg " NOT updated\n";
             }
         }
@@ -208,6 +229,8 @@
     }
 }
 
+logmsg "SUMMARY:\n$update packages found up-to-date\n";
+
 if($missing) {
     logmsg "$missing listed packages lacked autocheck URL\n";
 }

_______________________________________________
http://cool.haxx.se/mailman/listinfo/curl-www-commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.