chiark / gitweb /
Take out lock in db-idempotent-populate too
[ypp-sc-tools.db-live.git] / yarrg / commod-email-processor
index d2f0e819f6ef8c0f41626424fe13beb624d4f088..de68fbad98250c24cb43199cb1316e7dc4f79a0f 100755 (executable)
@@ -49,6 +49,12 @@ use strict (qw(vars));
 use POSIX;
 use MIME::Parser;
 
+BEGIN {
+    my $selfdir= $0;
+    $selfdir =~ s,/+[^/]*$,,;
+    chdir("$selfdir") or die "$selfdir $!";
+}
+
 use Commods;
 use CommodsDatabase;
 
@@ -111,7 +117,9 @@ sub main () {
     db_setocean($md{'ocean'});
     my $dbfn= db_filename();
     (stat $dbfn) or die "stat database $dbfn failed $!\n";
+    db_writer();
     db_connect();
+    db_onconflict(sub { print STDERR "temporary failure: @_\n"; exit 75; });
 
     my ($islandid) = $dbh->selectrow_array(
               "SELECT islands.islandid
@@ -200,7 +208,7 @@ sub main () {
 
     pipethrough_run_finish($pt, 'gunzip <$deduped_tsv.gz');
 
-    print "\n";
+#    print "\n";
     $dbh->commit();
 
     # select * from ((buy natural join commods) natural join stalls) natural join islands;