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/PublicInbox/Over.pm | |
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/PublicInbox/Over.pm')
-rw-r--r-- | lib/PublicInbox/Over.pm | 7 |
1 files changed, 3 insertions, 4 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; |