* [PATCH] over: do not delete {filename} on connect
@ 2023-10-08 19:46 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-10-08 19:46 UTC (permalink / raw)
To: spew
---
lib/PublicInbox/Over.pm | 22 ++++++++--------------
lib/PublicInbox/OverIdx.pm | 5 +----
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index e3a8adb1..e070c39b 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -16,16 +16,13 @@ use List::Util (); # for max
sub dbh_new {
my ($self, $rw) = @_;
- my $f = delete $self->{filename};
- if (!-s $f) { # SQLite defaults mode to 0644, we want 0666
- if ($rw) {
- require PublicInbox::Syscall;
- my ($dir) = ($f =~ m!(.+)/[^/]+\z!);
- PublicInbox::Syscall::nodatacow_dir($dir);
- open my $fh, '+>>', $f or die "failed to open $f: $!";
- } else {
- $self->{filename} = $f; # die on stat() below:
- }
+ my $f = $self->{filename};
+ # SQLite defaults mode to 0644, we want to respect umask
+ if (!-s $f && $rw) {
+ require PublicInbox::Syscall;
+ my ($dir) = ($f =~ m!(.+)/[^/]+\z!);
+ PublicInbox::Syscall::nodatacow_dir($dir);
+ open my $fh, '+>>', $f or die "failed to open $f: $!";
}
my (@st, $st, $dbh);
my $tries = 0;
@@ -76,10 +73,7 @@ sub new {
sub dbh_close {
my ($self) = @_;
- if (my $dbh = delete $self->{dbh}) {
- delete $self->{-get_art};
- $self->{filename} = $dbh->sqlite_db_filename;
- }
+ delete @$self{qw(dbh -get_art)};
}
sub dbh ($) { $_[0]->{dbh} //= $_[0]->dbh_new } # dbh_new may be subclassed
diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm
index 5cea3706..512a2cdb 100644
--- a/lib/PublicInbox/OverIdx.pm
+++ b/lib/PublicInbox/OverIdx.pm
@@ -460,10 +460,7 @@ sub dbh_close {
sub create {
my ($self) = @_;
- my $fn = $self->{filename} // do {
- croak('BUG: no {filename}') unless $self->{dbh};
- return;
- };
+ my $fn = $self->{filename} // croak('BUG: no {filename}');
unless (-r $fn) {
require File::Path;
my ($dir) = ($fn =~ m!(.*?/)[^/]+\z!);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-08 19:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-08 19:46 [PATCH] over: do not delete {filename} on connect Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).