diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-06-05T14·17+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-06-05T14·25+0200 |
commit | 75e12b8e666aa0b689f6b654d37c84be912ff6d4 (patch) | |
tree | 313e1a88e272f21e79b4afd857b4c21d70fe22ef /scripts | |
parent | f0576d67756fedca0010d20aaed2e9cffd24a108 (diff) |
download-from-binary-cache.pl: Fix race condition
Fixes the error "DBD::SQLite::db do failed: column url is not unique".
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/download-from-binary-cache.pl.in | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index a47d3579e35a..08d22ea63f72 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -265,11 +265,12 @@ sub getAvailableCaches { elsif ($1 eq "Priority") { $priority = int($2); } } - $dbh->do("insert into BinaryCaches(url, timestamp, storeDir, wantMassQuery, priority) values (?, ?, ?, ?, ?)", + $dbh->do("insert or replace into BinaryCaches(url, timestamp, storeDir, wantMassQuery, priority) values (?, ?, ?, ?, ?)", {}, $url, time(), $storeDir, $wantMassQuery, $priority); - my $id = $dbh->last_insert_id("", "", "", ""); + $queryCache->execute($url); + $res = $queryCache->fetchrow_hashref() or die; next if $storeDir ne $Nix::Config::storeDir; - push @caches, { id => $id, url => $url, wantMassQuery => $wantMassQuery, priority => $priority }; + push @caches, { id => $res->{id}, url => $url, wantMassQuery => $wantMassQuery, priority => $priority }; } @caches = sort { $a->{priority} <=> $b->{priority} } @caches; |