From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/3] imap_tracker: prepare for use with lei
Date: Thu, 22 Apr 2021 07:08:20 -0200 [thread overview]
Message-ID: <20210422090822.18869-2-e@80x24.org> (raw)
In-Reply-To: <20210422090822.18869-1-e@80x24.org>
We'll support nodatacow as we do in other SQLite DBs
---
lib/PublicInbox/IMAPTracker.pm | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/PublicInbox/IMAPTracker.pm b/lib/PublicInbox/IMAPTracker.pm
index 6d4fb227..bcf7af2e 100644
--- a/lib/PublicInbox/IMAPTracker.pm
+++ b/lib/PublicInbox/IMAPTracker.pm
@@ -62,21 +62,27 @@ VALUES (?, ?, ?)
}
sub new {
- my ($class, $url) = @_;
+ my ($class, $url, $dbname) = @_;
- # original name for compatibility with old setups:
- my $dbname = PublicInbox::Config->config_dir() . "/imap.sqlite3";
+ unless (defined($dbname)) {
+ # original name for compatibility with old setups:
+ $dbname = PublicInbox::Config->config_dir() . '/imap.sqlite3';
- # use the new XDG-compliant name for new setups:
- if (!-f $dbname) {
- $dbname = ($ENV{XDG_DATA_HOME} //
- (($ENV{HOME} // '/nonexistent').'/.local/share')) .
- '/public-inbox/imap.sqlite3';
+ # use the new XDG-compliant name for new setups:
+ if (!-f $dbname) {
+ $dbname = ($ENV{XDG_DATA_HOME} //
+ (($ENV{HOME} // '/nonexistent').
+ '/.local/share')) .
+ '/public-inbox/imap.sqlite3';
+ }
}
if (!-f $dbname) {
require File::Path;
require File::Basename;
+ require PublicInbox::Spawn;
File::Path::mkpath(File::Basename::dirname($dbname));
+ open my $fh, '+>>', $dbname or die "failed to open $dbname: $!";
+ PublicInbox::Spawn::nodatacow_fd(fileno($fh));
}
my $self = bless { lock_path => "$dbname.lock", url => $url }, $class;
$self->lock_acquire;
next prev parent reply other threads:[~2021-04-22 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 9:08 [PATCH 0/3] lei import: network sync things Eric Wong
2021-04-22 9:08 ` Eric Wong [this message]
2021-04-22 9:08 ` [PATCH 2/3] lei import: --incremental default for NNTP and IMAP Eric Wong
2021-04-22 9:08 ` [PATCH 3/3] lei import|convert: drop --no-kw aliases Eric Wong
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
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210422090822.18869-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).