Commit Graph

1844 Commits

Author SHA1 Message Date
Rodolfo García Peñas (kix)
9aa2344fd4 Reformat offlineimap/ui/debuglock.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:55:52 +02:00
Rodolfo García Peñas (kix)
1b385dfafb Reformat offlineimap/ui/Curses.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:55:07 +02:00
Rodolfo García Peñas (kix)
1df1a39b11 Reformat offlineimap/folder/Maildir.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:53:38 +02:00
Rodolfo García Peñas (kix)
8ed3d1ca9a Reformat offlineimap/folder/LocalStatus.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:52:56 +02:00
Rodolfo García Peñas (kix)
80ee751243 Reformat offlineimap/folder/IMAP.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:51:25 +02:00
Rodolfo García Peñas (kix)
3d1360a7e3 Reformat offlineimap/folder/GmailMaildir.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:50:46 +02:00
Rodolfo García Peñas (kix)
7be7a70d85 Reformat offlineimap/repository/Base.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:49:37 +02:00
Rodolfo García Peñas (kix)
b64430e035 Reformat offlineimap/repository/__init__.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:48:41 +02:00
Rodolfo García Peñas (kix)
3a1b25c204 Reformat offlineimap/folder/UIDMaps.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:48:04 +02:00
Rodolfo García Peñas (kix)
eafd9eb51d Reformat offlineimap/folder/Maildir.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:46:43 +02:00
Rodolfo García Peñas (kix)
265de25460 Reformat offlineimap/folder/LocalStatusSQLite.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:45:15 +02:00
Rodolfo García Peñas (kix)
cb95bc87b0 Reformat offlineimap/folder/LocalStatus.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:43:52 +02:00
Rodolfo García Peñas (kix)
da1788db53 Reformat offlineimap/folder/IMAP.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:43:09 +02:00
Rodolfo García Peñas (kix)
2f97dda6d9 Reformat offlineimap/folder/GmailMaildir.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:42:20 +02:00
Rodolfo García Peñas (kix)
af18230a2a Reformat offlineimap/folder/Gmail.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:41:19 +02:00
Rodolfo García Peñas (kix)
9ebdbe47ee Reformat offlineimap/folder/Base.py
Add some spaces, remove lines,... now format is better (lintian).
2020-08-29 19:39:31 +02:00
Rodolfo García Peñas (kix)
18d2e972ac Mail now is typle of bytes convert to str
This patch saves the tuple and discard the bytes/str (now bytes).

Then, convert the tuple elements to str (from bytes).
2020-08-29 19:00:28 +02:00
Rodolfo García Peñas (kix)
a88a9cf28e ui init is lintian clean
This patch only adds an space between the hash and the first character.
2020-08-29 09:51:31 +02:00
Rodolfo García Peñas (kix)
7ba9ca1cca Maildir set is a builtin in python3
set() is a builtin, it is already included.
2020-08-29 09:22:23 +02:00
Rodolfo García Peñas (kix)
99f85737c5 Removed python2 code in imaputil
This code is marked as python2, could be removed.
2020-08-29 09:07:15 +02:00
Rodolfo García Peñas (kix)
a655fa4fc2 threadutil imports not used
These imports are not used.
2020-08-29 09:04:07 +02:00
Rodolfo García Peñas (kix)
aebd530aaf threadutil imports without try except
Python 2 is not supported now. The import is the same in try and except.
2020-08-29 09:03:39 +02:00
Rodolfo García Peñas (kix)
ead8b157af CustonConfig imports withou try except
Python 2 is not supported now. The import is the same in try and except.
2020-08-29 09:02:16 +02:00
Rodolfo García Peñas (kix)
1618505d3b Machine imports withou try except
Python 2 is not supported now. The import is the same in try and except.
2020-08-29 09:00:30 +02:00
Rodolfo García Peñas (kix)
46c677151a UIBase imports without try except
Python 2 is not supported now. The import is the same in try and except.
2020-08-29 08:58:53 +02:00
Rodolfo García Peñas (kix)
3711954908 Folder name is already utf8
We don't need decode it.
2020-08-28 20:31:00 +02:00
Rodolfo García Peñas (kix)
36bfbdf7d6 Get the month number
This patch gets the month number using datetime library.

I removed the function Mon2num. The list is not used now, it is removed
too.

I need change the regex in the compile to get the fields. Now is str,
not binary, so I remored the 'b'.
2020-08-28 20:05:52 +02:00
Rodolfo García Peñas (kix)
e61e77cf40 Convert bytes to string in IMAP folder
Convert the IMAP reply to string.
2020-08-28 17:25:06 +02:00
Rodolfo García Peñas (kix)
1379c32c5a IMAP do not use single quotes on fetch
The IMAP command is:

C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])

not

C: A654 FETCH '2:4' (FLAGS BODY[HEADER.FIELDS (DATE FROM)])

The single quotes must be removed.
2020-08-28 17:18:29 +02:00
Rodolfo García Peñas (kix)
bb5b1f2dcf Encode folder name before md5
Avoid the error:

Unicode-objects must be encoded before hashing
2020-08-28 16:51:11 +02:00
Rodolfo García Peñas (kix)
22dfbd7a54 Split the IMAP folders
This patch modifies two files. First, we need split using '', not '""'.
Else we don't split anything.

OTOH, we need convert the bytes to string, then we can parse the folder
names.
2020-08-28 16:35:00 +02:00
Rodolfo García Peñas (kix)
c9a4b1fefa Add quotes in empty LIST calls
I need add this to get the imap LIST folders.
2020-08-28 16:03:15 +02:00
Rodolfo García Peñas (kix)
6fa099ff74 bundled_imaplib2 encode removed cr
This patch removes the cr in the encoding call. It avoids a crash.
2020-08-28 13:37:09 +02:00
Rodolfo García Peñas (kix)
6378c722b0 Do not use binary in the plain auth
Changed from binary to string in plain auth.
2020-08-28 13:06:31 +02:00
Rodolfo García Peñas (kix)
e84e932df4 Changed wrong comparison equal 2020-08-28 12:49:03 +02:00
Rodolfo García Peñas (kix)
5e356b0bf5 Removed codecs
I removed these calls to codecs because I got the error:

ValueError: can't have text and binary mode at once
2020-08-28 12:38:15 +02:00
Rodolfo García Peñas (kix)
476c485a52 Using standard imaplib2.py
This is the standard imaplib2 file.
2020-08-28 11:48:16 +02:00
Rodolfo García Peñas (kix)
75ce6e71f3 Comparison error 2020-08-28 03:33:49 +02:00
Rodolfo García Peñas (kix)
6ec6111896 2to3 main 2020-08-28 03:32:43 +02:00
Rodolfo García Peñas (kix)
0c58628c3b Remvoed Debug variable
I removed this variable.

The default level now is 3, not 5.
2020-08-28 02:59:37 +02:00
Rodolfo García Peñas (kix)
62209db06e Popen uses default buffer size
From the ipamlib2.
2020-08-28 02:28:35 +02:00
Rodolfo García Peñas (kix)
938bf647f1 Moving to imaplib2 python3 start
This patch only changes non-important parts, like imports,
comments, and more.
2020-08-27 22:53:16 +02:00
Rodolfo García Peñas (kix)
a6c5e96eb5 Force bundled_imaplib2
I am forcing to use the bundled. I will modify this library
to make it similar to imaplib2 for python3
2020-08-27 22:18:19 +02:00
Nicolas Sebrecht
ba4ecea9e4 v7.3.0
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-08-19 19:17:53 +02:00
Nicolas Sebrecht
9c6a1760b4 imaplib2 v2.101
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:50:29 +02:00
Ilias Tsitsimpis
beaaf77a1a Do not use TIMEOUT_MAX for Condition.wait()
On some architectures, using threading.TIMEOUT_MAX for the timeout
parameter can overflow causing Condition.wait() to return immediately.
Instead of relying on TIMEOUT_MAX, remove it and wait forever.

Signed-off-by: Ilias Tsitsimpis <iliastsi@debian.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:16:04 +02:00
Julien Cristau
0a831b3cab Use SSLContext if available so we send SNI
Fixes https://github.com/imaplib2/imaplib2/issues/5

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:13:35 +02:00
Nicolas Sebrecht
741b33b455 imaplib2 v2.100
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:10:21 +02:00
Ben Cotterell
8d5b22bd09 Don't expect trailing space on command completion
While trying to see why I couldn't get my emails from an Exchange server
I found this:

[imap]: 41:31.42 someserver.com handler _put_response(IOMC1 OK)
[imap]: 41:31.42 someserver.com handler unexpected response: 'IOMC1 OK'

And shortly after that the connection was closed. IOMC1 is just the
unique tag for the session.

The pattern looks for the tag, a number, a word like "OK" or something,
*then a space*, then optionally some data.

If the data aren't there it shouldn't be expecting a space.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-18 23:04:26 +02:00
Olivier Mehani
0d5496ba0a implement Happy Eyeballs
This allows OfflineIMAP to not stall on malfunctional IPv6 connections,
and fall-back to a functional IPv4 connection, if faster, as described
in RFC6555.

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-10 14:36:53 +02:00
Nicolas Sebrecht
06ed00a211 v7.2.4
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-06-08 11:32:57 +02:00
Nicolas Sebrecht
801893cc73 make portalocker really optional
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-04-27 14:56:17 +02:00
kimim
2806f40071 use portable locker to support cygwin in Windows
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-04-27 14:37:44 +02:00
Nicolas Sebrecht
0d865c2e36 repository/IMAP: update copyright header date
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:48:59 +01:00
Kyle Altendorf
57a43f5bba mkdir -p alike folder creation
When creating a folder in one command on Gmail you end up with
one tag such as 'x/y/z' instead of three nested tags such as 'z'
inside of 'y' inside of 'x'.  Creating each layer individually
results in the desired nested label structure.

This was tested in a personal transfer of email from a remote
IMAP server to Gmail.

OfflineIMAP/offlineimap#335
OfflineIMAP/offlineimap#598

Signed-off-by: Kyle Altendorf <sda@fstab.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:45:57 +01:00
Nicolas Sebrecht
5c735fd327 v7.2.3
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-17 00:31:19 +01:00
Mart Lubbers
c9f71b0c64 add checks in curses ui for small windows
addch() and addstr() throw an exception if text has to be printed
outside of the window. This may occur if the terminal is very small.
Such erroneous prints are no-ops now.

Signed-off-by: Mart Lubbers <mart@martlubbers.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/595
2019-02-13 16:32:02 +01:00
Nicolas Sebrecht
137130fbd0 v7.2.2
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-22 18:46:34 +01:00
Robbie Harwood
096aa07650 Handle empty token with complete GSSAPI context
This fixes a potential traceback when we try to unwrap(None).

Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-14 21:28:30 +01:00
Nicolas Sebrecht
a51064e83a maxage: always compute the remote cache list for min_uid
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/581
Tested-by: https://github.com/ianbrody
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-12-11 09:29:37 +01:00
Frode Aannevik
8692799e65 Fix expired oauth2_access_token
Use `expires_in` from the oauth2 response
to reset the oauth2_access_token before
it expires

divides the `expires_in` by 2 to ensure
the access_token is cleared before it
expires

ref: https://github.com/OfflineIMAP/offlineimap/issues/536

Signed-off-by: Frode Aannevik <frode.aa@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-11-18 21:07:54 +01:00
Philippe Loctaux
af3a35ae30 offlineimap/utilis/distro.py: identation fix
Fixed a indentation style.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-17 18:49:04 +02:00
Philippe Loctaux
761e10e8b1 Add Archlinux to list of supported distros
There is a bug with `platform.linux_distribution()`, which returns an
empty value on Archlinux with python2.

This bug is fixed in python3, but *will not* be fixed in python2.

This patch fixes that issue with a dirty hack: on archlinux, there is a
file that can be used to detect an archlinux machine. that file is
`/etc/arch-release`. if the file exists, then the OS variable will be
set to "linux-arch".

You can learn more about that issue on the python bug platform:
https://bugs.python.org/issue20454

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-17 18:49:04 +02:00
Nicolas Sebrecht
d9301254ff fix dates in copyright lines
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-13 01:15:01 +02:00
Philippe Loctaux
2890dec37f Added ssl certfile on osx for openssl pacakge on homebrew
A certfile was already specified for osx but only with MacPorts,
this patch adds the certfile given with the package `openssl` with
homebrew.

You can get more info with the command `brew info openssl` on osx with
homebrew and openssl installed.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-10 12:48:17 +02:00
Philippe Loctaux
7af4728d62 Add Archlinux to list of supported distros
get_os_name returns linux-arch on Archlinux, so add a line for linux-arch to __DEF_OS_LOCATIONS.

Signed-off-by: Philippe Loctaux <loctauxphilippe@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-08-10 12:42:29 +02:00
Benedikt Heine
ce9a1981c1 Chain tls_level and ssl_version only if ssl is enabled
If the tls_level is set to a cipherset other than tls_compat, the
ssl cipherset has to get specified extra, if ssl is used.

But if the user explicitly disabled SSL, and set tls_level to anything
else than tls_compat required the user to explicitly set ssl_version,
which is contradicting.

Signed-off-by: Benedikt Heine <bebe@bebehei.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-07-02 18:44:08 +02:00
Benedikt Heine
d3ba837900 Fix typo in exception message
Signed-off-by: Benedikt Heine <bebe@bebehei.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-07-02 18:44:08 +02:00
Carnë Draug
c9005cd4ff Check if username is provided before trying plain authentication.
If the username value is not provided on the configuration file, then
username if of NoneType and NULL.join will bomb since Nones can't be
joined with strings.  So check if username is empty and raise an
exception if so.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/558
Signed-off-by: David Miguel Susano Pinto <carandraug+dev@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:17:35 +02:00
Carnë Draug
5f9474e10d Print username instead of accountname when asking for password
When asking for a password interactively, the username is never
displayed which may hide problems (typos on the configuration, or
issues on offlineimap parsing of the config file).  The hostname,
port, and account name are already displayed when establishing the
connection.  When asking for password, the account name is displayed
again.  Change it to display the username.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/558
Signed-off-by: David Miguel Susano Pinto <carandraug+dev@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:17:35 +02:00
Nicolas Sebrecht
11313a9b9c v7.2.1
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-16 15:08:07 +02:00
Nicolas Sebrecht
b5ffa1c163 imapserver: fix copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-07 18:39:08 +02:00
Robbie Harwood
17cfb63db6 Pass username through in GSSAPI connections
Fix bug in GSSAPI auth where the username was not being negotiated.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/541
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Tested-by: Frank Lenormand <lenormf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-06-07 18:36:58 +02:00
Nicolas Sebrecht
fc61c6fd30 Gmail: allow parenthesis in labels
Reported-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Tested-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/545
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-18 02:10:56 +02:00
Nicolas Sebrecht
356bd0b78f Merge branch 'fingerprint-colons' into next
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:41:22 +02:00
velleto
c126b4286d Allow users to keep colons between each hex pair of server certificate fingerprint in configuration file.
Signed-off-by: velleto <rr@velleto.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:39:59 +02:00
velleto
b150daaa49 Added support for sha512, sha384, sha256, sha224 hashing algorithms to calculate server certificate fingerprints.
Signed-off-by: velleto <rr@velleto.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:38:06 +02:00
velleto
5180b964d8 Removed uneccessary call of list() on zip() object.
Signed-off-by: velleto <rr@velleto.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:38:06 +02:00
velleto
ac9ed47262 Changed the 'exception raised' message, to be more understandable.
Signed-off-by: velleto <rr@velleto.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:38:06 +02:00
Edgar HIPP
89b40ec3af Make CTRL-C message more clear
Signed-off-by: Edgar Hipp <ehipp@hotmail.fr>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-01 16:21:57 +02:00
Eygene Ryabinkin
3a807d0f2b Create filenames with no path separators in them
We use current hostname as the element of the unique file name.
Sometimes there is non-/24 zone delegation,
{{{
$ host 144.206.233.65
65.233.206.144.in-addr.arpa is an alias for 65.26/64.233.206.144.in-addr.arpa.
}}}
as per RFC 2317,
  https://www.rfc-editor.org/rfc/rfc2317.txt

So on Un*x systems we may run into having path separator inside
the file name.  Not good, things will choke.  Prevented this
by substituting all appeared path separators in the return value.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Tested-at: my MacOSX instance, my FreeBSD instances
2018-04-09 20:09:56 +03:00
Nicolas Sebrecht
a6de848a23 v7.2.0
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Tested-by: Remi Locherer <remi.locherer@relo.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-04-07 20:17:52 +02:00
Robbie Harwood
88724949fa Port to python-gssapi from pykerberos
python-gssapi has a visible, active upstream and a more pleasant
interface.  python-gssapi is present in most distributions, while
pykerberos is slated for removal from Fedora/RHEL/CentOS.

Github-ref: https://github.com/OfflineIMAP/offlineimap/pull/529
Tested-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-03-02 16:24:36 +01:00
Musashi69
c8847ccff9 make UI output show local AND remote dirs involved
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/525
Signed-off-by: Friedemann Schorer friedemann@schorers.org
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-02-24 01:13:40 +01:00
Nicolas Sebrecht
67d35dbbcb v7.1.5
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Tested-by: Remi Locherer <remi.locherer@relo.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-01-13 13:55:23 +01:00
Nicolas Sebrecht
0d6a9a44da maxage: don't consider negative UIDs when computing min UID
With new emails we could have negative UIDs in come use cases. Exclude these
from the list of UIDs. The negative UIDs lead to invalid SEARCH command:

 SEARCH command error: BAD ['Could not parse command']. Data: FMAO19 SEARCH (UID -4:*)

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/512
Tested-by: https://github.com/shubhamkrm
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-12-22 22:01:00 +01:00
Nicolas Sebrecht
e802f5fbd5 folder: IMAP: improve search logging
Log when exception occured during search command, too.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/512
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-12-22 15:13:51 +01:00
John Ferlito
3c6b07b25f Add missing space to output string
It was previously printing "Upgrading LocalStatus cache from version 1to version 2 for XXX"

Signed-off-by: John Ferlito <johnf@inodes.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-11-26 18:05:10 +01:00
Nicolas Sebrecht
9805d3e7af no UIDPLUS: improve logging on failures
When there is not UIDPLUS we have to figure the UID by our means. When this
process fails, we don't know if the email was successfully uploaded. This patch
provides better logs to explain what happened.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-11-12 22:40:06 +01:00
Nicolas Sebrecht
681e271fc0 v7.1.4
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 15:23:29 +01:00
Nicolas Sebrecht
5836970d51 utf8foldernames: fix missing decode argument
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/502
Tested-by: https://github.com/pprw
Reviewed-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 00:45:32 +02:00
Nicolas Sebrecht
a79263bb31 utf8foldernames: support --delete-folder with UTF-8 folder name
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/505
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 00:44:39 +02:00
Thomas Merkel
ee17e3dc3c Fix: if any tunnel (preauth_tunnel or transport_tunnel) the hostname should not be required
It's required to modify my change 1ce596d713
because a hostname shouldn't be needed if any tunnel is used. Both tunnels
provide a regular IMAP interface which is used by offlineimap.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/503
Reported-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Thomas Merkel <tm@core.io>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-27 20:03:17 +02:00
Nicolas Sebrecht
e1a6feb2d5 v7.1.3
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Tested-by: Remi Locherer <remi.locherer@relo.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-08 15:58:10 +02:00
Nicolas Sebrecht
6b64f87462 provide non-zero exit code & display configuration mismatch error at the end of the run
This behaviour is what users would expected most. The error message is about
utf8foldernames and decodefoldernames.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:24:12 +02:00
Nicolas Sebrecht
12de158ca2 Merge branch 'uliska/utf8foldernames' into next 2017-10-02 21:11:29 +02:00
Urs Liska
8b398f3aa8 utf8: Safeguard against use of old *and* new option
The new 'utf8foldernames' will not work together with the existing
'decodefoldernames' option (which will be documented in the next
commit). Therefore this commit will check for this condition and
abort the synchronization of a misconfigured account before doing
any changes.
Other accounts are not affected.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
ef3299b7ce Remove some unnecessary whitespace (in existing code)
Addresses https://github.com/OfflineIMAP/offlineimap/pull/498#discussion_r141672756

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
36d726763d utf8: implement utf8foldernames option
If utf8foldernames is enabled on account level all folder names read
from the IMAP server will immediately be reencoded to UTF-8. Names
will be treated as UTF-8 as long as the IMAP server isn't contacted again,
for which they are reencoded to IMAP4-UTF-7.

This means that any further processing such as nametrans, folderfilter
etc. will act upon the UTF-8 names, which will have to be documented
carefully.

NOTE 1:
GMail repositories and folders inherit from the IMAP... classes, so I don't
know yet if these changes have ugly side-effects. But web research suggests
that GMail IMAP folders are equally encoded in UTF-7 so that should work
identically here and incorporate the same improvements.

NOTE 2:
I could not test the behaviour with idlefolders as I didn't get this option
to work at all, not even with the latest stable version.

NOTE 3:
I *did* test to sync an IMAP repository against another IMAP repository.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
14d83dbf48 utf8: avoid dequoting IMAP folder names twice
Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
dca5f1846d utf8 (aside): Move code for decodefoldernames
While intending *not* to change the behaviour of the existing
decodefoldernames option this commit transparently improves
the coding.
So far this worked by overriding the folder's getvisiblename() method
which reads self.visiblename from and applies the conversion on
*every* invocation of getvisiblename().
This commit does the calculation once in the IMAPFolder's __init__.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
24b3f27e5f utf8: Add utf-7/8 conversion functions
This commit adds two functions
- imaputil.IMAP_utf8()
- imaputil.utf8_IMAP()
as an interface to the new imap4_utf_7 codec.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska
032376efad utf8: Add imap4_utf_7 codec
Add code to reencode IMAP folder names to regular utf-8.
This starts an implementation that will add a new config option
`utf8foldernames` on account level which will fix #299 and on the
long run replace the current `decodefoldernames` option.

This commit introduces code to register an `imap4_utf_7` codec
on which two-way conversion methods will later be built.

Original code by
(https://www.blogger.com/profile/16648963337079496096),
taken from
http://piao-tech.blogspot.no/2010/03/get-offlineimap-working-with-non-ascii.html

In the comment
http://piao-tech.blogspot.com/2010/03/get-offlineimap-working-with-non-ascii.html?showComment=1316041409339#c669880170006851138
indicates that this code is expected to be incorporated into offlineIMAP and therefore the author implicitly agrees to put it under this license.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Nicolas Sebrecht
31eee55672 accounts: error out when no folder to sync
Such error can be hit when the folderfilter is wrong and excludes all the
folders.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 02:43:47 +02:00
Thomas Merkel
1ce596d713 remotehost should not be required if transporttunnel is used
If the config option `transporttunnel` is used the option `remotehost` is not
needed, because the tunnel provide the IMAP connection.

Signed-off-by: Thomas Merkel <tm@core.io>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-09-21 18:50:57 +02:00
Nicolas Sebrecht
19442d0010 folder: Gmail: fix copyright header
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-08-15 01:24:23 +02:00
Nicolas Sebrecht
a5d9edc560 folder: Gmail: remove dead code
The support for the realdelete configuration option was removed because this
could lead to data loss.

See 51728ed to know more.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-08-15 01:19:56 +02:00
Nicolas Sebrecht
6079755b20 sqlite: provide better message error for insert
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/488
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-07-25 11:28:56 +02:00
Nicolas Sebrecht
e4bee74dad v7.1.2
Tested-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Tested-by: benutzer193 <registerbn@gmail.com>
Tested-by: Remi Locherer <remi.locherer@relo.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-07-10 16:58:50 +02:00
Nicolas Sebrecht
0903d5f33c increase imaplib2 requirement from v2.55 to v2.57
Suggested-by: Chris Coleman <christocoleman@yahoo.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-07-09 17:28:12 +02:00
Nicolas Sebrecht
212ed87509 imapserver: fix syntax error
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-06-30 16:42:47 +02:00
Nicolas Sebrecht
90244b7fa6 provide more details in error message when SSL fails on non-standard port
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-06-30 05:10:14 +02:00
Nicolas Sebrecht
ba47138616 folder/IMAP: introduce dedicated parsing for davmail (not supporting UIDPLUS)
Some returned responses end with ')' rather than 'UID XXX)' as expected.

BTW, a better policy could be to request for the 'X-OfflineIMAP' header only
rather than fetching all the headers and looking for it manually.

Also:
- Strip the output when error occurs: we don't need the full response unless
  'imap' debug mode is enabled.
- Improve the comments.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/479
Tested-by: https://github.com/secomi
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-06-27 20:32:58 +02:00
Nicolas Sebrecht
ce83efc3c7 folder/IMAP: improve the warning when we can't parse the returned UID
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/479
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-06-14 09:47:51 +02:00
Nicolas Sebrecht
05ff68c7e1 IMAP/IMAP: continue to sync if the local side does not return a valid UID on upload
There's no reason we should abort the full sync.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/479
Tested-by: https://github.com/secomi
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-06-14 09:12:15 +02:00
Nicolas Sebrecht
6b51d4ed49 v7.1.1
Tested-by: Remi Locherer <remi.locherer@relo.ch>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-05-28 18:08:54 +02:00
Nicolas Sebrecht
f37b97c61b maxage: use the remote folder first to compute min_uid
On each folder scan, we must compute the min_uid. Locally, this is done by
relying on the prefix timestamp in the filenames. If for whatever reason they do
not reflect the Date header of the email, changing maxage leads to undefined
behaviour.

To prevent from this, we rather rely on the remote folder. We assume that the
remotes are more reliable to provide correct sets of UIDs based on dates than we
are.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/384
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-05-21 00:50:04 +02:00
Nicolas Sebrecht
5d5ad62fa7 mbnames: don't duplicate entries in autorefresh mode
mbnames is initialized and written once in the run from OfflineImap.__sync().

However, the in-memory instance is fed with data at sync time for each folder
and the intermediate files are written as soon as all the folders are synced for
the account. All of this is done inside the SyncableAccount.__sync() method
while the syncrunner is looping on this.

This means that we duplicate entries for mbnames in each loop (most likely when
autorefresh is enabled).

It is wrong to have duplicates in mbnames for each account. Ignore duplicates
when adding data in the mbnames intermediate files.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/467
Reported-and-tested-by: Shin Kojima <shin@kojima.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-05-19 08:32:22 +02:00
Nicolas Sebrecht
ffeefd9459 env info (used by -V and banner): add openssl version
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-05-02 17:09:03 +02:00
Nicolas Sebrecht
22a163a768 display the imaplib and python versions for each normal run
Some users might use more than one python/imaplib version. This tends to make
debugging and support harder.

Displaying this information by default for each run should help.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-30 13:25:40 +02:00
Nicolas Sebrecht
8c04684f3b imapserver: provide some SSL info while in imap debug mode
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/457
Tested-by: Maximilian Kaul <https://github.com/maximiliankaul>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-30 12:15:08 +02:00
Nicolas Sebrecht
39b657194a XOAUTH2: don't try this authentication method when not configured
Checking if we have to run this authentication method once it's already passed
to imaplib2 is too late. Make the checks at correct time, before we try the
authentication method. IOW, before we call

  imapobj.authenticate('XOAUTH2', self.__xoauth2handler)

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/442
Tested-by: Klemens Schölhorn <klemens@schoelhorn.eu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-27 21:17:25 +02:00
Nicolas Sebrecht
e8f0e82f6c IMAP: UIDPLUS: correctly warn about weird responses from some servers
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/455
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-26 19:39:04 +02:00
Nicolas Sebrecht
e9d8e87a71 IMAP: UIDPLUS: improve error message on response error for new UID
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-26 18:40:51 +02:00
Ilias Tsitsimpis
7bc54d241c Acquire lock before updating the CursesLogHandler window
Make sure that we refresh the screen atomically, since the emit()
function may be called by more that one threads at a time.

Also, modify the draw_bannerwin() method which used to fail in case the
window would become too small. Make sure that the provided offsets to
the window.addstr() method are properly bounded.

Closes #160: blinkenlights display is broken
Tested-by: Cyril Brulebois
Tested-by: Gaudenz Steinlin
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-23 12:48:12 +02:00
Nicolas Sebrecht
f669b3ea2f v7.1.0
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-16 00:40:54 +02:00
Nicolas Sebrecht
2c6fac6449 folder/IMAP: improve handling of "matchinguids" error while searching headers
Raise OfflineImapError instead of ValueError.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/452
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-04-07 20:27:39 +02:00
Nicolas Sebrecht
c8206f24e1 remove support for the status_backend configuration option
Stop the run when this option is found. Migrating from the historical plain
text status cache is still supported.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-03-25 13:47:30 +01:00
Nicolas Sebrecht
ebf5fd527e folder: UIDMaps: ignore KeyError failure while removing keys
This would require more digging to understand how this is possible. I suspect
that a previous run has been interrupted.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/445
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-03-22 14:33:31 +01:00
Nicolas Sebrecht
c883160814 v7.0.14
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-03-11 13:22:18 +01:00
Nicolas Sebrecht
f9360ba2d7 bump from imaplib2 v2.55 to v2.57
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-03-05 13:28:47 +01:00
Nicolas Sebrecht
fc079499e9 prevent synchronization of identical folders from multiple threads
Use a mutex to lock the sync transaction, uniquely identified by the remote
folder name.

Serializing the syncs prevents any IDLE thread from syncing the same folder of
a concurrent autorefresh thread. Othewise, we could download new messages
twice, or read "one message past the last one" which in some cases creates a
duplicated messages.  Also prevents IDLE threads from reading new messages
before the autorefresh thread finishes synchronization.

Github-ref: #421
Originally-submitted-by: Michael Hohmuth <hohmuth@sax.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-02-28 19:16:18 +01:00
Stéphane Graber
e3bbf75feb Fix ipv6 configuration handling
According to documentation and the code, the following behavior is expected:

ipv6 = no
    AF_INET is used

ipv6 = yes
    AF_INET6 is used

ipv6 undefined
    AF_UNDEF is used

Unfortunately the code parsing the "ipv6" configuration option was
returning "False" rather than "None" when failing to locate the option,
making it impossible to detect whether "ipv6" isn't set or if it was set
to "false" and leading offlineimap to use AF_INET for the connection.

This fixes the use of offlineimap on hosts that occasionaly are
connected to IPv6-only networks.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-02-03 18:43:02 +01:00
Nicolas Sebrecht
4df06d57c3 SQLite: avoid concurrent writes on backend migration
The saveall() method must acquire the lock to make writes.

Reported-and-tested-by: Julien Cubizolles <j.cubizolles@free.fr>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-31 17:59:25 +01:00
Nicolas Sebrecht
c1df95b7d3 v7.0.13
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-27 19:49:42 +01:00
Nicolas Sebrecht
ba52030923 folder: IMAP: improve error message when Dovecot returns any data for UID FETCH
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/429
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-24 19:11:16 +01:00
Nicolas Sebrecht
6c0828b77c folder: IMAP: add missing whitespace in error message
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-24 16:08:41 +01:00
Chris Smart
eb2bd80851 init: register SIGABRT and handle as per SIGUSR2
systemd supports a watchdog (via the WatchdogSec service file option)
which will send the program a SIGABRT when the timer expires, however
currently this causes offlineimap to be killed immediately.

This patch registers SIGABRT and handles it in the same manner as
SIGUSR2, so that the current synchronisation is completed before the
program exits safely.

This makes offlineimap more flexible and robust for persistent setups
that make use of holdconnectionopen and autorefresh options.

For example, it may be useful in assisting with the occasional
situation where offlineimap may not return successfully after a suspend
and resume.

To make use of this, users could add the following to the [Service]
section of their systemd offlineimap service file (restart every 5
minutes):

Restart=on-watchdog
WatchdogSec=300

Signed-off-by: Chris Smart <mail@csmart.io>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-23 14:20:07 +01:00
Nicolas Sebrecht
11655cb613 repository: IMAP: correctly check the response while listing remote folders
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/423
Reported-by: Periklis Tsirakidis <periklis.tsirakidis@mayflower.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-22 19:20:32 +01:00
lkcl
dab5737265 learn repository retrycount configuration option
Allow retrying the download of messages more than twice.

Signed-off-by: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-12-19 12:55:55 +01:00
lkcl
dda27e0962 learn authproxy configuration option
Allow to use a another proxy for authentication than for IMAP.

Signed-off-by: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-12-19 12:20:19 +01:00
Nicolas Sebrecht
d5edf2dc11 v7.0.12
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-30 22:40:59 +01:00
Abdo Roig-Maranges
91486482cc repository: Base: fix typo in folder variable name
Probably fixes #417.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-30 22:33:05 +01:00
Darshit Shah
b5a4925efc Enable environment variable expansion on Repository.localfolders
Commit e51ed80e claims to add tilde and environment variable expansion
to multiple locations including Repository.localfolders. However, this
particular options seems to have been missed in that commit, and
apparently no one noticed till date

Signed-off-by: Darshit Shah <darnir@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-30 19:22:57 +01:00
Nicolas Sebrecht
ed79e56f8e v7.0.11
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-30 14:33:44 +01:00
Nicolas Sebrecht
2e2684d445 repository: Base: fix folder structure comparison
481efa95f6 is wrong to assume the local nametrans is set up and working.

Now, we correctly check that the local folder name is the same once both
nametrans are applied to itself. This check is only done when we have to create
the folder on remote.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/413
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-30 14:27:33 +01:00
Nicolas Sebrecht
683ae2b77b v7.0.10
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-28 19:10:28 +01:00
Abdo Roig-Maranges
5c59d3ecbf repository: Base: fix name of the status folder
When creating a folder on the remote, the status folder was created
using the remote folder name, but then Account assumed the statusfolder
name matched the local folder. Correct this.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-28 14:11:01 +01:00
Nicolas Sebrecht
481efa95f6 repository: Base: rework the structure folders comparison
Ensure we work on the correct names when coparing the structures.

This might revert changes made in 22641331c1 and would require mode
checks. However, having correct folder structure comparison is more important
than having the not official UTF-8 support.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/405
Tested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-22 22:29:29 +01:00
Nicolas Sebrecht
04ae3c8dad folder: IMAP: display error message before starting next try
Fetching messages is tried more than once. Display the error message at correct
time.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-22 00:58:14 +01:00
Nicolas Sebrecht
54bbe79930 accounts: minor code refactoring
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-20 20:22:37 +01:00
Nicolas Sebrecht
e3ad46a27b Merge branch 'avar/pr404' into next
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-17 17:58:13 +01:00
Ævar Arnfjörð Bjarmason
7b59d6b3ae GMail: Add ability to set a custom host/port/ssl etc.
The GMail repository added in 81b86fb has the restriction that you
can't override the host/port/ssl etc. There's no good reason for this,
and I'd like to use some of the defaults while connecting to GMail via
an stunnel, i.e.:

    $ grep -v -e ^# -e ^$ .stunnel.work-gmail-imap
    foreground = yes
    debug = info
    pid =
    [work-imap-gmail-ssl-tunnel]
    client = yes
    accept = 127.0.0.1:1431
    connect = imap.gmail.com:993
    delay = yes

And then in my .offlineimaprc:

    type = Gmail
    remotehost = localhost
    remoteport = 1431
    ssl = no

While I was at it I also allowed overriding all the other previously
hardcoded options, e.g. the "oauth2_request_url" can now be overridden
to e.g. a local non-https proxy to sniff & debug the traffic going
over the wire.

This doesn't break any existing configuration, since we still use the
provided defaults. It just allows odd uses like my own to use this
repository while e.g. not having to supply "trashfolder", "spamfolder"
& "oauth2_request_url". While I'm at it document in the
offlineimap.conf that we're setting those options to defaults in this
repository.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-17 17:53:38 +01:00
Abdo Roig-Maranges
c4fcd9f7f2 fix remaining instance of check_uid_validity refactoring
Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-10 11:24:33 +01:00
Nicolas Sebrecht
673edb0b9f fix the profile mode
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-08 07:11:33 +01:00
Nicolas Sebrecht
5eb131ef2b accounts: minor refactoring
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-08 07:11:30 +01:00
Nicolas Sebrecht
01a744a0f8 folder: Maildir: actually try to use Delivery-Date if Date is broken
This value is used to set the timestamp prefix in the filename.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-07 23:14:32 +01:00
Nicolas Sebrecht
e452c344d9 minor code refactoring
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-07 23:03:40 +01:00
Nicolas Sebrecht
9606cfcfc1 don't allow negative values for autorefresh
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-07 23:01:15 +01:00
Nicolas Sebrecht
15eac5b3cb repository: Gmail: fix copyright line
Minor code rewriting, too.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-05 19:27:21 +01:00
Nicolas Sebrecht
0fe4562269 manual: add known issues entry about XOAUTH2 "invalid_grant"
- Split the manual asciidoc source file.
- Improve the Makefile to build the manuals.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/374
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-05 19:20:39 +01:00
altruizine
d88b8d52e7 Add OpenSUSE to list of supported distros
get_os_name returns linux-opensuse on OpenSUSE, so add a line for linux-opensuse to __DEF_OS_LOCATIONS.

Signed-off-by: Michael Hohmuth <hohmuth@sax.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-03 16:35:24 +01:00
Stéphane Albert
22641331c1 Fix decodefoldernames not applying in folder sync
sync_folder_structure wasn't applying utf7 decoding before comparing
folders.
This is a minimal fix that only modifies one function so it doesn't
interfere with rest of the code.

Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-02 16:10:15 +01:00
Stéphane Albert
175d49e8a2 Fix mbnames writing with folders using utf-8
Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-02 12:30:03 +01:00
Stéphane Albert
75f16106da Fix utf7 decode error not caught
Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-02 12:27:00 +01:00
Stéphane Albert
2d885fda4c Fix md5 folder generation wanting unicode
Using standard offlineimap without specific utf8 nametrans makes
offlineimap crash when generating md5 of the folder because the
foldername is already an str.

Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-02 12:24:31 +01:00
Xudong Zhang
a92816bd6d fix bug: should not compare list to int
Signed-off-by: Xudong Zhang <felixmelon@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-11-02 05:34:30 +01:00
Nicolas Sebrecht
a5e32929b6 v7.0.9
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-29 10:18:44 +02:00
Giel van Schijndel
b6ede627a9 SQLite: make postponing transaction committing possible.
This should significantly improve performance when used to write large
amounts of messages.

This feature is enabled through the fsync configuration option.

Code refactorize around fsync.

This addresses #390 (although it doesn't necessarily fix all instances
of that problem yet).

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/390
Originally-written-by: Giel van Schijndel <me@mortis.eu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-28 20:31:57 +02:00
Nicolas Sebrecht
41c9694488 UIDMaps: ensure we don't update the map file in dry run mode
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-24 20:03:44 +02:00
Nicolas Sebrecht
2ac68d82aa UIDMaps: prevent from leaving a truncated map file
If the map file is not properly written (e.g. due to unexpected kill)
offlineimap might wrongly consider some UIDs to have been deleted from the local
side which could lead to data loss.

Use a temporary map file rather than writing to the map file directly.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-24 20:02:53 +02:00
Ilias Tsitsimpis
0a635bd236 Fix flickering in Blinkenlights UI
Do not call resizeterm(), unless is_term_resized() returns True. This
breaks the busy-loop where resizeterm() pushes a KEY_RESIZE onto the
FIFO causing the screen to be redrawn indefinitely (Issue #290).

Also, clear and refresh the main window after it has been resized. This
hopefully fixes the problem where Blinkenlights UI becomes unreadable
after terminal resize (Issue #160).

Closes #160: blinkenlights display is broken
Closes #290: ncurses flicker with blinkenlights UI
Bug-Debian: https://bugs.debian.org/671087
Bug-Debian: https://bugs.debian.org/809676
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-20 14:11:51 +02:00
Nicolas Sebrecht
5d705f26e2 UIDMaps: reorder imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-18 14:58:02 +02:00
Nicolas Sebrecht
097d1e07fa folder: IMAP: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-18 13:56:35 +02:00
Nicolas Sebrecht
b81cb6f5e2 v7.0.8
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-08 10:10:56 +02:00
Ilias Tsitsimpis
e8b79c6bff Import ui before threadutil to resolve circular dependency
The `threadutil` module depends on the `ui` module, which cycle depends
on `threadutil` through the `Curses` module.

The `ui` module had been loaded before the `threadutil` module, breaking
the above circular dependency, but this was changed in a recent code
refactoring, preventing the `Curses` module from being loaded with the
following exception:

  File "./offlineimap.py", line 23, in <module>
    from offlineimap import OfflineImap
  File "offlineimap/offlineimap/__init__.py", line 20, in <module>
    from offlineimap.init import OfflineImap
  File "offlineimap/offlineimap/init.py", line 30, in <module>
    from offlineimap import globals, threadutil, accounts, folder, mbnames
  File "offlineimap/offlineimap/threadutil.py", line 25, in <module>
    from offlineimap.ui import getglobalui
  File "offlineimap/offlineimap/ui/__init__.py", line 28, in <module>
    from offlineimap.ui import Curses
  File "offlineimap/offlineimap/ui/Curses.py", line 27, in <module>
    from offlineimap.threadutil import ExitNotifyThread
ImportError: cannot import name ExitNotifyThread

Fix the above error by ensuring that the `ui` module gets loaded before
the `threadutil` module. Please note that the above fix is temporary,
and we should refactor the modules to not have circular dependencies.

Bug-Debian: https://bugs.debian.org/839862
Reported-by: Neil McGovern <neilm@debian.org>
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-07 08:47:21 +02:00
Stéphane Albert
57e6eda617 Fix implicit call to unicode() from UI functions
BaseFolder now exposes an __unicode__ method so that function needing
unicode transcoding don't crash due to ascii encoding errors.

Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-23 17:40:44 +02:00
Nicolas Sebrecht
c0f4fa44eb imapserver: minor code cleaning: reorder methods
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-23 16:27:22 +02:00
Nicolas Sebrecht
e57b499145 v7.0.7
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 04:03:25 +02:00
Nicolas Sebrecht
3d3e66fbb2 ensure logs are in bytes for PLAIN authentication
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 03:54:41 +02:00
Nicolas Sebrecht
95c82b91be minor: utils: distro: fix copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 00:51:42 +02:00
Espen Henriksen
4ee1518b64 Add gentoo cert path for OS-DEFAULT
Signed-off-by: Espen Henriksen <dev@henriksen.is>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 00:41:20 +02:00
Nicolas Sebrecht
c287ecb7cc set singlethreadperfolder configuration option when in idle mode
Git-reference: https://github.com/OfflineIMAP/offlineimap/issues/376
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-20 02:36:56 +02:00
Nicolas Sebrecht
bd4b968f1d repository: IMAP: cache the idle folders in memory
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-20 02:36:56 +02:00
Nicolas Sebrecht
dbcfc0b173 idle: protect all calls to imapobj.noop() (coonection might be dropped)
Some code refactoring.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-13 04:41:31 +02:00
Nicolas Sebrecht
41764a0ec6 mbnames: add info output messages in dry run mode
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-26 01:44:15 +02:00
Nicolas Sebrecht
520e99d8b6 mbnames: remove non-required argument
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-26 01:38:03 +02:00
Nicolas Sebrecht
38c6785636 XOAUTH2: raise error if string 'error' is in the response
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/374
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-23 01:19:30 +02:00
Nicolas Sebrecht
59d254c783 v7.0.6
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-21 20:43:03 +02:00
Nicolas Sebrecht
71d86b6d47 XOAUTH2: improve error message while trying to get access token
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/338
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-21 20:30:19 +02:00
Nicolas Sebrecht
1884fd7ef6 show python version for -V CLI option
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-15 04:53:23 +02:00
Nicolas Sebrecht
9c386154bb XOAUTH2: correctly strip values for evaluated credentials
Don't use lambda anymore as default value.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:33:37 +02:00
Nicolas Sebrecht
13043b5877 XOAUTH2: strip newlines of the returned values for the eval configuration options
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:17:09 +02:00
Nicolas Sebrecht
00e6627299 XOAUTH2: function was changed to not have argument
Fix the default lambda.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:13:25 +02:00
Nicolas Sebrecht
b4fe69028b XOAUTH2: let the user call the evaluated functions in the configuration
Don't pass the account name to the function returned by eval. This allows the
user to define his own arguments.

This fix the code according to the documentation provided in offlineimap.conf.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/372
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 22:35:09 +02:00
James E. Blair
560363ef73 learn singlethreadperfolder configuration option
To further ensure that messages are synchronized strictly in UID
order, this option can be set to cause only one thread to be used
to synchronise an individual folder, though other folders may
be synchronized simultaneously by other threads.

Signed-off-by: James E. Blair <corvus@gnu.org>
Based-on-patch-by: James E. Blair <corvus@gnu.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 02:20:51 +02:00
James E. Blair
a5ea1827fb folder: Base: sort message UID list
Return a sorted list of UIDs in getmessageuidlist.

Some MUAs (and their users) like to display messages in UID order
(or "order received").  If offlineimap is used in IMAP<->IMAP mode,
then the order messages are received by the second IMAP server will
be different because offlineimap iterates over a UID list produced
from the keys of a dictionary, which is unsorted.

This change sorts that list of UIDs so that both IMAP servers will
have their messages in the same order (except those times where
messages are appended to folders on both repositories between
syncs).

Signed-off-by: James E. Blair <corvus@gnu.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 01:56:13 +02:00
Nicolas Sebrecht
d263af91e0 Maildir: add missing exception instance "as e" in except clause
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-13 16:28:32 +02:00
Nicolas Sebrecht
f62f5b5656 v7.0.5
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-10 15:03:17 +02:00
Wieland Hoffmann
ad2070f0d4 Remove an unused import
Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 22:40:45 +02:00
Nicolas Sebrecht
473be4c66f folder: Base: minor fix style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 17:36:26 +02:00
Nicolas Sebrecht
6b313aabd3 don't delete messages in local cache in dry-run mode
This makes dry-run consitent when called more than once.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/370
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 15:02:03 +02:00
Łukasz Żarnowiecki
f634546980 explicitly set __hash__ of Base class to None
This suppressing the warning generated when running offlineimap on
python2 with -3 switch:

  offlineimap/folder/Base.py:29: DeprecationWarning: Overriding __eq__
  blocks inheritance of __hash__ in 3.x

Since this object is mutable it should not be hashable.

From Python documentation[1]:

  A class that overrides __eq__() and does not define __hash__() will
  have its __hash__() implicitly set to None.

Therefore old behaviour is preserved.

[1] https://docs.python.org/3/reference/datamodel.html

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-06 01:32:26 +02:00
Łukasz Żarnowiecki
48611398e0 imapserver: change lambdas with map to list comprehension
It is more readable and returns a list.

This continues work done in 19c4330.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-05 00:06:26 +02:00
Nicolas Sebrecht
cbd1a8929a folder: IMAP: change raw assert to OfflineImapError
There is not reason to block remainings actions on first error on UID STORE.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-04 02:21:22 +02:00
Christopher League
c7434ea46c Fix typo in format string in machineui
This was causing the error message "not all arguments converted during
string formatting." Specifically:

```
% offlineimap -u machineui
OfflineIMAP 7.0.4
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
msg:protocol:MainThread:7.2.0
msg:initbanner:MainThread:OfflineIMAP+7.0.4%0A++Licensed+under+the+GNU+GPL+v2+or+any+later+version+%28with+an+OpenSSL+exception%29
msg:registerthread:Account+sync+MYHOST:MYHOST
msg:acct:Account+sync+MYHOST:MYHOST
error::Account+sync+MYHOST:ERROR%3A+While+attempting+to+sync+account+%27MYHOST%27%0A++not+all+arguments+converted+during+string+formatting
msg:acctdone:Account+sync+MYHOST:MYHOST
msg:threadExited:MainThread:Account+sync+MYHOST
msg:unregisterthread:MainThread:Account+sync+MYHOST
msg:terminate:MainThread:0%0A%0A
```

Signed-off-by: Christopher League <league@contrapunctus.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-04 02:20:10 +02:00
Nicolas Sebrecht
fc54fe52a0 folder: IMAP: add 'imap' debug output before calling FETCH
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-03 01:25:39 +02:00
Nicolas Sebrecht
91f13e9b03 v7.0.4
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-02 20:26:49 +02:00
Nicolas Sebrecht
b19eaebad1 ConfigHelperMixin must be new-style class to not break inheritance
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/363
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 04:26:25 +02:00
Nicolas Sebrecht
e460228bfc v7.0.3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 01:56:10 +02:00
Nicolas Sebrecht
203c28f21f add the repository name when connecting
Otherwise, it might be impossible to know which account is connecting when more
than one is syncing.

Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 01:44:27 +02:00
Nicolas Sebrecht
9aa5afa951 XOAUTH2: fix the *_eval configuration options
They introduce a regression not allowing to discard the XOAUTH2 method when
expected.

The default lambda did not take the "account_name" argument.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/362
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-29 16:38:58 +02:00
Nicolas Sebrecht
b4e33eeac4 XOAUTH2: use one "public" attribute everywhere for self.oauth2_request_url
Improve documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 18:35:33 +02:00
Nicolas Sebrecht
be285e522d IMAP: don't take junk data for valid mail content
OfflineIMAP frequently delivers mail files to the Maildir consisting exclusively
of a single ASCII digit in IDLE mode. IMAPFolder.getmessage expects 'data' to be
of the form

  [(fetch-info, message-body)]

However, the imapobj.uid call in getmessage returns a list of *all* pending
untagged FETCH responses.  If any message flags were changed in the selected
IMAP folder since the last command (by another client or another thread in
OfflineIMAP itself), the IMAP server will issue unsolicited FETCH responses
indicating these flag changes (RFC3501, section 7).  When this happens, 'data'
will look like, for example

  ['1231 (FLAGS (\\Seen) UID 5300)',
   '1238 (FLAGS (\\Seen) UID 5318)',
   ('1242 (UID 5325 BODY[] {7976}', message-body)]

Unfortunately, getmessage retrieves the message body as data[0][1], which in
this example is just the string "2", and this is what gets stored in the mail
file.

Multi-threaded OfflineIMAP with IDLE or holdconnectionopen is particularly
susceptible to this problem because flag changes synced back to the IMAP server
on one thread will appear as unsolicited FETCH responses on another thread if it
happens to have the same folder selected.  This can also happen without IDLE or
holdconnectionopen or even in single-threaded OfflineIMAP with concurrent access
from other IMAP clients (webmail clients, etc.), though the window for the bug
is much smaller.

Ideally, either imaplib2 or getmessage would parse the fetch responses to find
the response for the requested UID.  However, since IMAP only specifies
unilateral FETCH responses for flag changes, it's almost certainly safe to
simply find the element of 'data' that is a tuple (perhaps aborting if there is
more than one tuple) and use that.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/162
Based-on-patch-by: Austin Clements <amdragon@MIT.EDU>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 07:18:23 +02:00
Nicolas Sebrecht
0ef11a8392 folder/IMAP: code style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 06:51:47 +02:00
Nicolas Sebrecht
0b824bdc49 offlineimap.conf: allow non-spaces in the account list
Commit c992f58530 pretends to fix this bug it doesn't.

Regression introduced in v7.0.0.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/355
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 04:06:52 +02:00
Nicolas Sebrecht
88e8a4895e minor code enhancements
- More class inherit from object.
- Initialize all attributes.
- Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 00:42:35 +02:00
Nicolas Sebrecht
7fe90b8e0d properly ignore folders with invalid characters (sep) in their name
Commit 6b28071b0f makes the check once nametrans is applied. This is wrong
because separators are valid characters in names returned by nametrans. E.g:

  "Sent" -> "[Gmail]/Sent"

Make the check against the raw name of the folder, instead.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/353
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 18:45:18 +02:00
Nicolas Sebrecht
ce1de85157 v7.0.2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 16:38:55 +02:00
Philipp Meier
560d631706 GmailMaildir: don't add a tuple to syncmessagesto_passes
Regression introduced by 59b712ecbc.

Fix-found-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Philipp Meier <github@philipp.meier.name>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 16:29:34 +02:00
Nicolas Sebrecht
b521b98d99 offlineimap.conf: learn to evaluate oauth2 related options
Introduce:
- oauth2_client_id_eval
- oauth2_client_secret_eval
- oauth2_access_token_eval
- oauth2_refresh_token_eval

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/307
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 04:25:18 +02:00
Ævar Arnfjörð Bjarmason
a1efae0703 Remove double import of "six"
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 03:19:14 +02:00
Nicolas Sebrecht
65295b01ef v7.0.1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:53:18 +02:00
Nicolas Sebrecht
2f060aa269 Merge tag 'v6.7.0.3' into next
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:47:19 +02:00
Nicolas Sebrecht
ecef22a16c v6.7.0.3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:46:22 +02:00
Nicolas Sebrecht
77a6f9a7ba LocalStatusSQLite: code refactoring around database lock
Backported-from: 05e5b9c6bb
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:58:09 +02:00
Nicolas Sebrecht
05e5b9c6bb LocalStatusSQLite: code refactoring around database lock
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:56:36 +02:00
Nicolas Sebrecht
038a433f69 backport: sqlite: properly serialize operations on the databases
1. There is one database per folder and sqlite requires to serialize the
writings. Instead of locking at LocalStatusSQLiteFolder object level, introduce
a new DatabaseFileLock object which is shared across threads. This fixes the
concurrent writes issues that some users might experience by duplications or
flags restored to the previous state.

2. Close the database only when we are sure no other threads will use the
connection on a *per-file* basis. Previous fix 677afb8d8f is wrong
because the same lock is shared for all the databases.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:00:17 +02:00
Nicolas Sebrecht
3c42913120 sqlite: properly serialize operations on the databases
1. There is one database per folder and sqlite requires to serialize the
writings. Instead of locking at LocalStatusSQLiteFolder instance level,
introduce a new DatabaseFileLock object which is shared across threads. This
fixes the concurrent writes issues that some users might experience by
duplications or flags restored to the previous state.

2. Close the database only when we are sure no other threads will use the
connection on a *per-file* basis. Previous fix 677afb8d8f is wrong
because the same lock is shared for all the database files.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 01:57:25 +02:00
Nicolas Sebrecht
5aa2a883f0 local status: deletemessagelist: remove broken code
This did not work and is not usefull since the purge() method was introduced in
1410a391bc. Actually, the purge() does what deletemessagelist() was supposed to
achieve.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 15:06:39 +02:00
Nicolas Sebrecht
fbc3b15888 IMAP/IMAP: fix import issue about UIDMaps
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 05:26:57 +02:00
Nicolas Sebrecht
03859e89c3 improve error message when ssl_version must be set due to the tls_level
Improve the ssl documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 03:29:25 +02:00
Nicolas Sebrecht
c992f58530 offlineimap.conf: allow non-spaces in the account list
Regression introduced in v7.0.0.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/355
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-24 19:39:43 +02:00
Nicolas Sebrecht
284c66b04a v7.0.0
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:56:43 +02:00
Nicolas Sebrecht
41fdd4ee78 v6.7.0.2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:34:04 +02:00
Nicolas Sebrecht
e753766284 sqlite: close the database when no more threads need access
It's required to have more than one connection to the database for the
maxconnections configuration option to work with threads. However,
connection.close() is closing all the connections. Only close the connection
when no more thread need it.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:30:38 +02:00
Nicolas Sebrecht
677afb8d8f sqlite: close the database when no more threads need access
It's required to have more than one connection to the database for the
maxconnections configuration option to work with threads. However,
connection.close() is closing all the connections. Only close the connection
when no more thread need it.

Backported-from: 856b74407bd7f634cae5a8c2d9b84e13d14c12d2
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 09:19:09 +02:00
Nicolas Sebrecht
034c55a278 --info: allow user to enter a password
Change from basic UI to ttyui.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/352
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 01:44:38 +02:00
Nicolas Sebrecht
59b712ecbc remove dead code: the description of the passes is never used
Some minor style fixes.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-18 18:41:41 +02:00
Nicolas Sebrecht
80dcf76414 fix attribute name _utime_from_header
Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-16 21:25:14 +02:00
Nicolas Sebrecht
59f5da5e9e Maildir: OfflineImapError is missing the severity argument
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-16 18:02:01 +02:00
Nicolas Sebrecht
1a96d588d5 fix: configparser does not know about python types like u""
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/347
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-13 14:02:25 +02:00
Nicolas Sebrecht
742e53a4b4 v7.0.0-rc5
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-12 16:15:33 +02:00
Nicolas Sebrecht
ff0c1a2efc --help: make it clear --delete-folder is for the remote repository
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-09 02:11:36 +02:00
Nicolas Sebrecht
3f059c638a --help: move -V option up
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-09 01:28:51 +02:00
Nicolas Sebrecht
2e81331a3c learn --delete-folder CLI option
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:34:25 +02:00
Nicolas Sebrecht
bb8e03bced init: factorize code to get active accounts
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:34:25 +02:00
Nicolas Sebrecht
d2dbe2c544 mbnames: enable action at correct time
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:31:30 +02:00
Nicolas Sebrecht
175479d919 mbnames: fix the filename extension for the intermediate files
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-06 01:15:33 +02:00
Nicolas Sebrecht
b3209e38c0 mbnames: output message on errors while reading intermediate files
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-06 00:38:43 +02:00
Nicolas Sebrecht
218b3802c0 v7.0.0-rc4
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-04 04:05:37 +02:00
Nicolas Sebrecht
44a8cf3feb threadutil: use 'with' statements for lock
Improve code for waiting the accountThreads.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:03:14 +02:00
Nicolas Sebrecht
29e06a60f9 learn to not download UIDs defined by the user
Allow users to workaround offending emails that offlineimap can't download.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
f0096391fc folder: IMAP: fix wrong comment
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
1086d0dd69 minor: improve "Copy message" output
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
f4210dc11c folder: IMAP: improve style of comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
296c8a6146 UIDMaps: correctly protect from concurrent writes
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:00:21 +02:00
Nicolas Sebrecht
cd43cd5b3b UIDMaps: code cleanups and improvements
- Use more 'with' statements.
- Remove dead code: 'dolock' was never used.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:00:21 +02:00
Nicolas Sebrecht
c32b409413 UIDMaps: fix copyright line and re-order imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:58:45 +02:00
Nicolas Sebrecht
7945e10a76 correctly reraise errors with six
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:56:14 +02:00
Nicolas Sebrecht
69c0080323 learn --mbnames-prune CLI option
This is usefull to remove dangling entries for removed accounts or if mbnames is
not enabled anymore.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:54:41 +02:00
Nicolas Sebrecht
4ef05fe6e1 minor: init: re-order imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:54:13 +02:00
Nicolas Sebrecht
932e826d7c folder: Maildir: add comments about FMD5 issues
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:53:45 +02:00
Nicolas Sebrecht
6b28071b0f don't sync folders with local separator characters in their names
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/148
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:52:34 +02:00
Nicolas Sebrecht
548a6a57f1 folder: Gmail: use consistent copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-28 02:29:30 +02:00
Nicolas Sebrecht
38f28d15aa v7.0.0-rc3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:47:26 +02:00
Nicolas Sebrecht
1da5bd938c folder: Base: fix line continuation
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:27:11 +02:00
Nicolas Sebrecht
65d4c94f07 don't try to copy messages with UID == 0
Output a warning so that we can dig into this. For now, the patch doesn't fix
the root cause. If the server returns UID 0 as valid UID number, this must be
ignored as soon as possible.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/336
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:13:03 +02:00
Nicolas Sebrecht
9a7603af37 minor: folder: Base: improve style and comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:03:27 +02:00
Nicolas Sebrecht
e8509a04e6 remove dead code
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:09:03 +02:00
Nicolas Sebrecht
cf5698b6a6 repository: IMAP: minor improvements
Make it clear what value is the default.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:02:28 +02:00
Nicolas Sebrecht
ac2a547ec4 learn to disable STARTTLS
Some servers might have this feature broken.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/207
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:01:01 +02:00
Nicolas Sebrecht
1410a391bc avoid removing of data when user removed a maildir
When a maildir is removed it must be considered new for the sync. However, the
local cache of the folder remains. This means the sync of the folder removes all
the missing emails.

Avoid loosing of data for users not aware of the local cache by removing any
pre-existing status cache of a folder when we actually want to create the
database.

Improve style.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/333
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:00:23 +02:00
Nicolas Sebrecht
08e17de7e2 require usernames and passwords to be UTF-8 encoded
- Learn to support UTF-8 characters where it was not supported for usernames and
  passwords (but for netrc).
- Fix the types in the code for both py2 and py3: we now expect unicode for
  usernames and passwords.

Unicode (UTF-8) is required only for variables with non-ASCII characters.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 16:57:22 +02:00
Nicolas Sebrecht
092264c8e7 fix: when called with -a, mbnames must not erase entries of other accounts
Make mbnames to work with intermediate files, one per account, in the JSON
format. The mbnames target is built from those intermediate files.

Github-Fix: https://github.com/OfflineIMAP/offlineimap/issues/66
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-25 17:33:42 +02:00
Nicolas Sebrecht
3a5becf6a7 bump from imaplib2 v2.53 to v2.55
- Expose more literals.
- Fix a type to bytes.
- Fix comment.

Changes submitted upstream by Łukasz and me.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-11 11:08:02 +02:00
Nicolas Sebrecht
e3fe848c6b minor code cleanups
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 19:03:02 +02:00
Nicolas Sebrecht
7fcd160911 GmailMaildir: quick mode is not compatible with utime_from_header
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 19:02:04 +02:00
Nicolas Sebrecht
8c9f63a9b5 repository/IMAP: add minor comment
Some minor cleanups on whitespaces.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 16:01:58 +02:00
Nicolas Sebrecht
8cca78b265 v6.7.0.1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 02:02:32 +02:00
Nicolas Sebrecht
3f70d9ef37 sqlite: open database when we use it rather than at instantiation time
Backported from 8e995a69bfa003ab822b55731429d84b3bc5626f.

We currently close the database as soon as possible while we handle the status
backend but this is still too early because autorefresh induces looping on this
code block.

Instead of delaying the closing outside of the loop, it's easier to delay the
opening as late as possible (inside the loop). The downside is that the database
is opened/closed more than once when autorefresh is enabled. The good news is
that this make the code much easier.

Fixes regression introduces by 6fb5700.

Reported-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 01:59:39 +02:00
Nicolas Sebrecht
b840e66d59 SQLite: close db when done
Backported from 6fb5700f94.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 01:59:14 +02:00
Nicolas Sebrecht
effe1d85a8 LocalStatusSQLite: remove dead code: sqlite import fails early
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-07 17:46:18 +02:00
Nicolas Sebrecht
a41fecd057 learn -V CLI option
Help users to get the versions while reporting bugs.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-07 00:36:57 +02:00
Nicolas Sebrecht
19ac578a50 sqlite was made mandatory: import error can fail at import time
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-06 15:18:29 +02:00
Nicolas Sebrecht
fd0198027a --info displays the imaplib2 version and whether it's the bundled or system one
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 15:23:53 +02:00
Nicolas Sebrecht
9902a116c0 init: improve style of code comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 15:23:51 +02:00
Nicolas Sebrecht
703ac7718d v7.0.0-rc2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 12:45:45 +02:00
Nicolas Sebrecht
acc9c3cf49 introduce a virtual imaplib2
The virtual imaplib2 first try to import imaplib2 when provided by the system.
If not provided or if the version is not supported, fallback on the bundled
imaplib2 version.

Distribution maintainers can now easily remove the bundled imaplib2 version if
they want to get it packaged outside of offlineimap.

We still want to provide imaplib2 by default because:
- this library is neither in Python core nor packaged by a lot of distributions;
- users expect to be able to run offlineimap by just downloading the tarball or
  after a git clone.

In order to avoid unexpected (too old) versions of imaplib2, we restrict the
supported versions of this librabry.

Reviewed-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 12:17:53 +02:00
Nicolas Sebrecht
922bed05a7 threading: improve comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 02:25:44 +02:00
Nicolas Sebrecht
56f473326a bump imaplib2 from v2.52 to v2.53
Be aware upstream has two versions of both 2.52 and 2.53.

This bump change is from

 commit a205409a0047732840505e534c07d8d85d2644a1
 Author: Piers Lauder <piers@janeelix.com>
 Date:   Sun Dec 27 20:55:04 2015 +1100

     Back out BINARY changes - not implemented correctly.

to

  commit 0596e7372fd3556d27ea55510b1e8cfa8370ec43
  Author: Piers Lauder <piers@janeelix.com>
  Date:   Fri Jun 3 11:58:40 2016 +1000

      new version of imaplib2.py

Original-imaplib2-patch-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-03 12:09:40 +02:00
Łukasz Żarnowiecki
48ae1a36c8 maildir: Create top level dir recursively
This patch fixes the situation when "localfolders" specifies path that
is more that one level deep and top directory does not exists.  Example
would be "localfolders = ~/Mail/a".  This especially relevant on the
first run.

In that case we would end up with unhandled exception causing
unexpected termination of the program.

Thread 'Account sync test' terminated with exception:
Traceback (most recent call last):
  File "/offlineimap/offlineimap/threadutil.py", line 172, in run
    Thread.run(self)
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/offlineimap/offlineimap/accounts.py", line 258, in syncrunner
    self.localrepos  = Repository(self, 'local')
  File "/offlineimap/offlineimap/repository/__init__.py", line 82, in __new__
    return repo(name, account)
  File "/offlineimap/offlineimap/repository/Maildir.py", line 40, in __init__
    os.mkdir(self.root, 0o700)
OSError: [Errno 2] No such file or directory: '/Mail/a'

By replacing call to "mkdir" with "makedirs" we can simply create
directories recursively.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-01 19:49:55 +02:00
Nicolas Sebrecht
f00cbeed5a IMAP: ignore UID with 0 as value when searching for UIDs
Some servers are broken: they return zero as valid UID and respond "BAD invalid
parameter: 0" on the FETCH command.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-25 03:33:06 +02:00
Nicolas Sebrecht
b14f37942a globals: use whitespaces instead of tabs
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-22 23:31:54 +02:00
Nicolas Sebrecht
bb1160f0ee minor: fix copyright date
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-20 18:20:07 +02:00
Nicolas Sebrecht
b8c3e51739 v7.0.0-rc1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 09:25:01 +02:00
Nicolas Sebrecht
a2a8a908ca threading: fix variable names about namespaces
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 08:36:23 +02:00
Nicolas Sebrecht
0b32e787c7 imapserver: use boolean where it makes sense
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 08:33:14 +02:00
Nicolas Sebrecht
46a6bcbf1c threading: suggeststhreads must honor CLI and conf options
There's no need to honor them twice.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 04:23:02 +02:00
Nicolas Sebrecht
e0fdcb3852 threading: improve variable names and factorize code
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 04:23:02 +02:00