diff options
author | Eric Wong <e@yhbt.net> | 2020-02-04 04:44:25 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-02-04 21:39:56 +0000 |
commit | 253a86b7bf4a3d81118e91f4ebb77844cfbd2b32 (patch) | |
tree | da6b875b9d5f38be331b59adcdd37b5708a4c65a /lib | |
parent | fea03df0e2e95ad3ac44ac46d9c31da97fa2fde9 (diff) | |
download | public-inbox-253a86b7bf4a3d81118e91f4ebb77844cfbd2b32.tar.gz |
No need to call ref() and do a string comparison. Add some extra tests using the {ReadOnly} attribute in DBI.pm.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Over.pm | 7 | ||||
-rw-r--r-- | lib/PublicInbox/OverIdx.pm | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index 0f8f433a..57c82bfc 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -14,17 +14,16 @@ use Compress::Zlib qw(uncompress); use constant DEFAULT_LIMIT => 1000; sub dbh_new { - my ($self) = @_; - my $ro = ref($self) eq 'PublicInbox::Over'; + my ($self, $rw) = @_; my $f = $self->{filename}; - if (!$ro && !-f $f) { # SQLite defaults mode to 0644, we want 0666 + if ($rw && !-f $f) { # SQLite defaults mode to 0644, we want 0666 open my $fh, '+>>', $f or die "failed to open $f: $!"; } my $dbh = DBI->connect("dbi:SQLite:dbname=$f",'','', { AutoCommit => 1, RaiseError => 1, PrintError => 0, - ReadOnly => $ro, + ReadOnly => !$rw, sqlite_use_immediate_transaction => 1, }); $dbh->{sqlite_unicode} = 1; diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index 5f1007aa..a966a710 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -20,7 +20,7 @@ use PublicInbox::Search; sub dbh_new { my ($self) = @_; - my $dbh = $self->SUPER::dbh_new; + my $dbh = $self->SUPER::dbh_new(1); $dbh->do('PRAGMA journal_mode = TRUNCATE'); $dbh->do('PRAGMA cache_size = 80000'); create_tables($dbh); |