+ Add support for untagged ESEARCH responses from RFC 4731.
+ pullimap: Use extended SEARCH commands (RFC 4731) if supported by
the server to search old mail and EXPUNGE them.
+ + pullimap, interimap: don't autocreate statefile or database in
+ long-lived mode (when --watch or --idle is set). Instead, an error
+ is raised if the statefile or database doesn't exist.
- Ensure the lower bound of UID ranges is at least 1.
- Fix manpage generation with pandoc >=2.1.
- Specify minimum Perl and Net::SSLeay versions.
use Getopt::Long qw/:config posix_default no_ignore_case gnu_compat
bundling auto_version/;
use DBI ();
+use DBD::SQLite::Constants ':file_open';
use Fcntl qw/F_GETFD F_SETFD FD_CLOEXEC/;
use List::Util 'first';
#############################################################################
# Open the database and create tables
-$DBH = DBI::->connect("dbi:SQLite:dbname=$DBFILE", undef, undef, {
- AutoCommit => 0,
- RaiseError => 1,
- sqlite_see_if_its_a_number => 1, # see if the bind values are numbers or not
- sqlite_use_immediate_transaction => 1,
-});
-$DBH->sqlite_busy_timeout(250);
-$DBH->do('PRAGMA locking_mode = EXCLUSIVE');
-$DBH->do('PRAGMA foreign_keys = ON');
-
{
+ my $dbi_data_source = "dbi:SQLite:dbname=".$DBFILE;
+ my %dbi_attrs = (
+ AutoCommit => 0,
+ RaiseError => 1,
+ sqlite_see_if_its_a_number => 1, # see if the bind values are numbers or not
+ sqlite_use_immediate_transaction => 1,
+ sqlite_open_flags => SQLITE_OPEN_READWRITE
+ );
+ # don't auto-create in long-lived mode
+ $dbi_attrs{sqlite_open_flags} |= SQLITE_OPEN_CREATE unless defined $CONFIG{watch};
+
+ $DBH = DBI::->connect($dbi_data_source, undef, undef, \%dbi_attrs);
+ $DBH->sqlite_busy_timeout(250);
+ $DBH->do('PRAGMA locking_mode = EXCLUSIVE');
+ $DBH->do('PRAGMA foreign_keys = ON');
+
my @schema = (
mailboxes => [
q{idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT},
die "Missing option statefile" unless defined $statefile;
$statefile = xdg_basedir( XDG_DATA_HOME => ".local/share", $NAME, $statefile );
- sysopen($STATE, $statefile, O_CREAT|O_RDWR|O_DSYNC, 0600) or die "Can't open $statefile: $!";
+ my $mode = O_RDWR | O_DSYNC;
+ # don't auto-create in long-lived mode
+ $mode |= O_CREAT unless defined $CONFIG{idle};
+
+ sysopen($STATE, $statefile, $mode, 0600) or die "Can't open $statefile: $!";
# XXX we need to pack the struct flock manually: not portable!
my $struct_flock = pack('s!s!l!l!i!', F_WRLCK, SEEK_SET, 0, 0, 0);
fcntl($STATE, F_SETLK, $struct_flock) or die "Can't lock $statefile: $!";