From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] over: do not delete {filename} on connect
Date: Sun, 8 Oct 2023 19:46:08 +0000 [thread overview]
Message-ID: <20231008194608.93886-1-e@80x24.org> (raw)
---
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!);
reply other threads:[~2023-10-08 19:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231008194608.93886-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).