aboutsummaryrefslogtreecommitdiffstats
path: root/interimap
diff options
context:
space:
mode:
Diffstat (limited to 'interimap')
-rwxr-xr-xinterimap19
1 files changed, 12 insertions, 7 deletions
diff --git a/interimap b/interimap
index 7781571..ac9550f 100755
--- a/interimap
+++ b/interimap
@@ -2,7 +2,7 @@
#----------------------------------------------------------------------
# Fast bidirectional synchronization for QRESYNC-capable IMAP servers
-# Copyright © 2015-2019 Guilhem Moulin <guilhem@fripost.org>
+# Copyright © 2015-2022 Guilhem Moulin <guilhem@fripost.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,17 +22,18 @@ use v5.14.2;
use strict;
use warnings;
-our $VERSION = '0.5.2';
+our $VERSION = '0.5.7';
my $NAME = 'interimap';
my $DATABASE_VERSION = 1;
use Getopt::Long qw/:config posix_default no_ignore_case gnu_compat
bundling auto_version/;
use DBI ':sql_types';
use DBD::SQLite::Constants ':file_open';
-use Fcntl qw/F_GETFD F_SETFD FD_CLOEXEC/;
+use Fcntl qw/O_WRONLY O_CREAT O_EXCL F_GETFD F_SETFD FD_CLOEXEC/;
use List::Util 'first';
-use Net::IMAP::InterIMAP 0.0.5 qw/xdg_basedir read_config compact_set/;
+use lib "./lib";
+use Net::IMAP::InterIMAP 0.5.7 qw/xdg_basedir read_config compact_set/;
# Clean up PATH
$ENV{PATH} = join ':', qw{/usr/bin /bin};
@@ -159,6 +160,12 @@ $SIG{TERM} = sub { cleanup(); exit 0; };
# Open (and maybe create) the database
{
+ # don't auto-create in long-lived mode
+ unless ($CONFIG{watch} or -e $DBFILE) {
+ sysopen(my $fh, $DBFILE, O_WRONLY | O_CREAT | O_EXCL, 0600) or die "Can't create $DBFILE: $!";
+ close $fh or warn "close: $!";
+ }
+
my $dbi_data_source = "dbi:SQLite:dbname=".$DBFILE;
my %dbi_attrs = (
AutoCommit => 0,
@@ -166,8 +173,6 @@ $SIG{TERM} = sub { cleanup(); exit 0; };
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);
@@ -286,7 +291,7 @@ sub list_mailboxes($) {
my ($m) = sort keys %$delims;
$imap->{delimiter} = delete $delims->{$m};
} else {
- # didn't get a non-INBOX LIST reply so we need to explicitely query
+ # didn't get a non-INBOX LIST reply so we need to explicitly query
# the hierarchy delimiter
get_delimiter($name, $imap, $ref);
}