]> git.donarmstrong.com Git - debbugs.git/blobdiff - bin/debbugs-loadsql
handle quick bug loading by checking the database for the last modified time
[debbugs.git] / bin / debbugs-loadsql
index d6096ba461ad0f38b60159fe5f7ad934aa9ae261..2edcd1ec32f4c9fd4f74c948e7145f3ce0958b87 100755 (executable)
@@ -119,18 +119,17 @@ my %options =
      progress        => 0,
     );
 
-my $gop = Getopt::Long::Parser->new();
-$gop->configure('pass_through');
-$gop->getoptions(\%options,
-                 'quick|q',
-                 'service|s',
-                 'sysconfdir|c',
-                 'progress!',
-                 'spool_dir|spool-dir=s',
-                 'verbose|v+',
-                 'quiet+',
-                 'debug|d+','help|h|?','man|m');
-$gop->getoptions('default');
+Getopt::Long::Configure('pass_through');
+GetOptions(\%options,
+           'quick|q',
+           'service|s=s',
+           'sysconfdir|c=s',
+           'progress!',
+           'spool_dir|spool-dir=s',
+           'verbose|v+',
+           'quiet+',
+           'debug|d+','help|h|?','man|m');
+Getopt::Long::Configure('default');
 
 pod2usage() if $options{help};
 pod2usage({verbose=>2}) if $options{man};
@@ -186,11 +185,15 @@ if ($options{progress}) {
 my ($subcommand) = shift @ARGV;
 if (not defined $subcommand) {
     $subcommand = 'help';
-    print STDERR "You must provide a subcommand; displaying help";
+    print STDERR "You must provide a subcommand; displaying usage.\n";
+    pod2usage();
+} elsif (not exists $subcommands{$subcommand}) {
+    print STDERR "$subcommand is not a valid subcommand; displaying usage.\n";
+    pod2uage();
 }
 
 my $opts =
-    handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments},$gop);
+    handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments});
 $subcommands{$subcommand}{function}->(\%options,$opts,$prog_bar,\%config,\@ARGV);
 
 sub add_bugs {
@@ -249,7 +252,10 @@ sub add_bugs {
                 print STDERR "Unable to stat $bug $!\n";
                 next;
             }
-            next if $stat->mtime < $time;
+            if ($options{quick}) {
+                my $rs = $s->resultset('Bug')->search({bug=>$bug})->single();
+                next if defined $rs and $stat->mtime < $rs->last_modified()->epoch();
+            }
             my $data = read_bug(bug => $bug,
                                 location => $initialdir);
             eval {
@@ -415,7 +421,7 @@ sub add_logs {
 }
 
 sub handle_subcommand_arguments {
-    my ($argv,$args,$gop) = @_;
+    my ($argv,$args) = @_;
     my $subopt = {};
     Getopt::Long::GetOptionsFromArray($argv,
                               $subopt,