diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2015-07-23 19:15:22 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-07-23 20:10:51 +0200 |
commit | b634b665a4a636460562ab0718770e0845da22a5 (patch) | |
tree | a125004dce9ec24b56c7d41f79b192cd2b3a734d /lib/Net/IMAP/Sync.pm | |
parent | f501dd5f09ca78c18fcde007e23337f05b1284b6 (diff) |
bugfix
Diffstat (limited to 'lib/Net/IMAP/Sync.pm')
-rw-r--r-- | lib/Net/IMAP/Sync.pm | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm index 517270b..0228f29 100644 --- a/lib/Net/IMAP/Sync.pm +++ b/lib/Net/IMAP/Sync.pm @@ -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'; } |