]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAPTracker.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / IMAPTracker.pm
index 6d4fb22748e90e399f7370f603e1d3712e73f78c..2fd66440df04ee540f5ce2f96e6e749d44a2e49e 100644 (file)
@@ -65,7 +65,7 @@ sub new {
        my ($class, $url) = @_;
 
        # original name for compatibility with old setups:
-       my $dbname = PublicInbox::Config->config_dir() . "/imap.sqlite3";
+       my $dbname = PublicInbox::Config->config_dir() . '/imap.sqlite3';
 
        # use the new XDG-compliant name for new setups:
        if (!-f $dbname) {
@@ -75,8 +75,11 @@ sub new {
        }
        if (!-f $dbname) {
                require File::Path;
-               require File::Basename;
-               File::Path::mkpath(File::Basename::dirname($dbname));
+               require PublicInbox::Spawn;
+               my ($dir) = ($dbname =~ m!(.*?/)[^/]+\z!);
+               File::Path::mkpath($dir);
+               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;