]> git.g-eek.se Git - interimap.git/commitdiff
bugfix
authorGuilhem Moulin <guilhem@fripost.org>
Thu, 23 Jul 2015 17:15:22 +0000 (19:15 +0200)
committerGuilhem Moulin <guilhem@fripost.org>
Thu, 23 Jul 2015 18:10:51 +0000 (20:10 +0200)
lib/Net/IMAP/Sync.pm

index 517270bc525085a9cecde03688fefe203bcdd05d..0228f29dfa04e160b4c452b672b957daf8af15af 100644 (file)
@@ -215,6 +215,16 @@ sub new($%) {
     my $self = { @_ };
     bless $self, $class;
 
+    # whether we're allowed to to use read-write command
+    $self->{'read-only'} = uc ($self->{'read-only'} // 'FALSE') ne 'TRUE' ? 0 : 1;
+
+    # where to log
+    $self->{STDERR} //= \*STDERR;
+
+    # the IMAP state: one of 'UNAUTH', 'AUTH', 'SELECTED' or 'LOGOUT'
+    # (cf RFC 3501 section 3)
+    $self->{_STATE} = '';
+
     if ($self->{type} eq 'preauth') {
         require 'IPC/Open2.pm';
         my $command = $self->{command} // $self->fail("Missing preauth command");
@@ -275,16 +285,6 @@ sub new($%) {
     # are considered.
     $self->{_MODIFIED} = {};
 
-    # whether we're allowed to to use read-write command
-    $self->{'read-only'} = uc ($self->{'read-only'} // 'FALSE') ne 'TRUE' ? 0 : 1;
-
-    # where to log
-    $self->{STDERR} //= \*STDERR;
-
-    # the IMAP state: one of 'UNAUTH', 'AUTH', 'SELECTED' or 'LOGOUT'
-    # (cf RFC 3501 section 3)
-    $self->{_STATE} = '';
-
     # wait for the greeting
     my $x = $self->_getline();
     $x =~ s/\A\* (OK|PREAUTH) // or $self->panic($x);
@@ -1182,7 +1182,7 @@ sub _select_or_examine($$$) {
     $command .= " (QRESYNC ($pcache->{UIDVALIDITY} $pcache->{HIGHESTMODSEQ} "
                            ."1:".($pcache->{UIDNEXT}-1)."))"
         if $self->_enabled('QRESYNC') and
-           ($pcache->{HIGHESTMODSEQ} // 0) > 0 and ($pcache->{UIDNEXT} // 0) > 0;
+           ($pcache->{HIGHESTMODSEQ} // 0) > 0 and ($pcache->{UIDNEXT} // 0) > 1;
 
     if ($self->{_STATE} eq 'SELECTED' and ($self->_capable('CONDSTORE') or $self->_capable('QRESYNC'))) {
         # A mailbox is currently selected and the server advertizes
@@ -1198,11 +1198,8 @@ sub _select_or_examine($$$) {
     }
 
     $self->{_STATE} = 'AUTH';
-    if ($self->_send($command) eq 'OK') {
-        $self->{_STATE} = 'SELECTED';
-    } else {
-        delete $self->{_SELECTED};
-    }
+    $self->_send($command);
+    $self->{_STATE} = 'SELECTED';
 }