]> 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 bcf7af2e11b5de2e63a5a30bd13dfc7fb159bda8..2fd66440df04ee540f5ce2f96e6e749d44a2e49e 100644 (file)
@@ -62,25 +62,22 @@ VALUES (?, ?, ?)
 }
 
 sub new {
-       my ($class, $url, $dbname) = @_;
+       my ($class, $url) = @_;
 
-       unless (defined($dbname)) {
-               # original name for compatibility with old setups:
-               $dbname = PublicInbox::Config->config_dir() . '/imap.sqlite3';
+       # original name for compatibility with old setups:
+       my $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));
+               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));
        }