]> git.donarmstrong.com Git - bin.git/commitdiff
add clear cache command
authorDon Armstrong <don@donarmstrong.com>
Sat, 8 Feb 2014 00:55:52 +0000 (16:55 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 8 Feb 2014 00:55:52 +0000 (16:55 -0800)
bibtex_to_paper

index 66fdf09324fe6f2b868b13fb9e43025ddbabc13c..5ac334ea9c086167fd5d260c9b9ece64cc6fa3f7 100755 (executable)
@@ -90,6 +90,7 @@ GetOptions(\%options,
            'bibtex|b=s@',
            'bibtex_cache|bibtex-cache|c=s',
            'pdfviewer|p=s',
+           'clear_cache|clear-cache!',
            'papers_directory|papers-directory=s@',
            'debug|d+','help|h|?','man|m');
 
@@ -123,6 +124,9 @@ sub main{
         }
     }
 
+    if (exists $options{clear_cache}) {
+        clear_cache($dbh,$sth);
+    }
     my %entries;
     if (exists $options{build_cache}) {
         $options{bibtex} //= [];
@@ -157,6 +161,12 @@ sub main{
 
 }
 
+sub clear_cache {
+    my ($dbh,$sth) = @_;
+    $sth->{clear_papers_cache}->execute();
+    $sth->{clear_bibtex_cache}->execute();
+}
+
 sub load_papers_into_database {
     my ($dbh,$sth,$dir) = @_;
 
@@ -393,6 +403,12 @@ SELECT * FROM bibtex WHERE bibtex_key LIKE ?;
 EOF
          select_bibtex_by_file_name => <<'EOF',
 SELECT * FROM bibtex WHERE file_name = ?;
+EOF
+         clear_papers_cache => <<'EOF',
+DELETE FROM papers;
+EOF
+         clear_bibtex_cache => <<'EOF',
+DELETE FROM bibtex;
 EOF
         );
     my $st;