From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 014AA1F934 for ; Thu, 22 Apr 2021 09:08:23 +0000 (UTC) From: Eric Wong 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 Message-Id: <20210422090822.18869-2-e@80x24.org> In-Reply-To: <20210422090822.18869-1-e@80x24.org> References: <20210422090822.18869-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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;