Previous commit e7ca5b25cb combined
checks for filtered folders in one place. However, it turns out there
was a reason to have them separate. getfolder() on a non-existent Maildir
fails and there might not be an equivalent local Maildir folder for a
filtered out IMAP folder.
Fix this by first checking if the remote folder should be filtered, and
only then retrieving the local folder (which should exist then).
This bug was found by our test suite!
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
the LocalStatus._folders cache was changed to be a dict that can be
searched for names. One instance were _folders was set to "None" was
accidentally left over. Fix this.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
commit e94642bb4d centralized folder filtering by using the
repository.should_sync_folder() function. Therefore there is no need
to check for folderfilter in the Maildir backend separately.
Origina patch by Dave, split into 3 by Sebastian
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rather than later when retrieving them by IMAP, we determine the
"sync_this" value of a folder on Folder() initialization.
This also fixes a bug where folder structure was not propagated when
a folder was filtered out but included in the folderincludes list.
Patch by Dave, split and modified slightly by Sebastian
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
- Factor out the code to find a local folder given a remote folder
Patch by Dave, split and modified by Sebastian.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
If we ask twice for a LocalStatusFolder via getfolder(), we would
get a newly created instance each time. This can lead to problems,
as e.g. write locks protecting files only work within the same Folder
instance. Make it so, that we cache all Folder instances that we have
asked for and hand back the existing one if we ask again for it,
rather than recreate a new instance.
Also, make getfolders() a noop for LocalStatus. We attempted to
derive the foldername from the name of the LocalStatusfile. However,
this is not really possible, as we do file name mangling
(".$" -> "dot", "/" -> ".") and there is no way to get the original folder
name from the LocalStatus file name anyway.
This commit could potentially solve the "file not found" errors, that people
have been seeing with their LocalStatusCache files. If we have 2
instances of a LocalStatusFolder pointing to the same file, our locking
system would not work.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
When logging to a file using the -l switch, we would still write an initial
banner to the file. This was never intended. Quiet should be really quiet
unless it experiences an error. Simplify the logging statement, to do nothing
if logevel is set to "WARNING" aka quiet.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
While looking at the code to investigate if an why we sometimes don't
seem to honor the write lock, I made it use the more modern "with lock:"
pattern.
Still have not found out how we could ever be using 2 instances of the
LocalStatusFolder for the same folder.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
If we throw an OfflineImapError in case of the Repository()
initialization, we display the nice error message and exit rather
than bomb out with a traceback. Misconfiguring a repository name in
the configuration file is now nicely pointed out to the user.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
When misconfiguring OLI, e.g. by specifying a repository name that was
not configured anywhere, we would bomb out with cryptic "NoSectionError".
Throw OfflineImapError that explains what has happened. We still need to
avoid throwing exceptions with Tracebacks here though.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
If 'readonly' is True, folders shouldn't be created (regardless of
'createfolders' option). With old behavior, instead folders were always created
when 'readonly' is True (even if 'createfolders' was also False), which is a
serious bug (offlineimap was creating folders in all read-only repositories).
'createfolders' should only play a role if 'readonly' is False, in which case
folders should only be created if 'createfolders' is True.
Submitted-by: Vladimir Nesov <robotact@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This will allow our callers who are capable of dealing with
readonly folders to properly detect this condition and act
accordingly.
One example is Gmail's "Chats" folder that is read-only,
but contains logs of the quick chats.
Minor Changelog improvements.
Tested-by: Abdó Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This will allow our callers who are capable of dealing with
readonly folders to properly detect this condition and act
accordingly.
One example is Gmail's "Chats" folder that is read-only,
but contains logs of the quick chats.
Tested-by: Abdó Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
As Gmail was only announcing the presence of the UIDPLUS extension
after we logged in, and we were then only getting server
capabilities before, a hack was introduced that checked the
existence of an APPENDUID reply, even if the server did not claim
to support it.
However, John Wiegley reports problems, where the APPENDUID would
be None, and we attempt to go this path (it seems that imaplib2
returns [None] if there is no such reply, so our test here for "!="
might fail. Given that this is an undocumented imaplib2 function
anyway, and we do fetch gmail capabilities after authentication,
this hack should no longer be necessary.
We had problems there earlier, where imapobj.response() would
return [None] although we had received a APPENDUID response from
the server, this might need more debugging and testing.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Somehow we failed if no dry-run setting had been specified in the config
file. This got caught thanks to extending the test suite with a stock
configuration.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
By default OfflineImap propagates new folders in both
directions. Sometimes this is not what you want. E.g. you might want
new folders on your IMAP server to propagate to your local MailDir,
but not the other way around. The 'readonly' setting on a repository
will not help here, as it prevents any change from occuring on that
repository. This is what the `createfolders` setting is for. By
default it is `True`, meaning that new folders can be created on this
repository. To prevent folders from ever being created on a
repository, set this to `False`. If you set this to False on the
REMOTE repository, you will not have to create the `Reverse
nametrans`_ rules on the LOCAL repository.
Also implement a test for this
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Reported by sharat87 in https://github.com/spaetz/offlineimap/pull/38,
he would often get an unhandled Exception when trying to
releaseconnection() a connection that was not in the pool of
connections.
The reason this could happen is that when folder.IMAP.quickchanged()
raises an Exception in select(), we would release the connection in the
"except" handling, and than release the same connection in the "finally"
clause, which led to the error. The right thing is to only release the
connection once, of course.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
We use python's SafeConfigParser, and this is a built in "feature" used
for interpolating variables. But it imples that '%' needs encoding as
'%%'.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
As reported by James Cook, we would not check the fingerprint of the SSL
server, as we were looking for the 'ssl' module in locals() rather than
globals(). Ooops!
Rather than using globals() though, I simply remove the by-now
superfluous check. We now rely on python2.6 and we unconditionally
import the SSL module in any case, so it needs to be there.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Add skeleton for maxage/maxsize documentation. Also remove the old
nametrans.rst from the old doc location.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
The warn() method tries to set the color to red. This leads to a garbled
tty after endwin() has been called. So lets simply use the UIBase
implementation.
Signed-off-by: Christoph Höger <christoph.hoeger@tu-berlin.de>
Add one test for each of the functions in offlineimap.imaputil, to make
sure they keep working. These functions tests the internal innards of
the offlineimap module rather than invoking offlineimap as a program.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Somehow we failed if no dry-run setting had been specified in the config
file. This got caught thanks to extending the test suite with a stock
configuration.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Somehow we failed if no dry-run setting had been specified in the config
file. This got caught thanks to extending the test suite with a stock
configuration.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
In 2.6 all logging classes are not the new-style ones, so they
have no mro() method and, thus, we can't use super() for them.
Since CursesLogHanler is singly-inherited method, there will
be no problems in usage of the explicit superclass name.
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
We autodetect the folder separator on IMAP servers and ignore any 'sep'
setting in the repository section for IMAP servers. Detect if there is
such a setting and warn the user about it.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
1) Fix test #4 by deleting all local mailfolders remaining from previous
tests, the mailfolder count will be off, otherwise.
2) Make folder deletion work in python3, it weirdly enough needs to be
quoted like this to work in python3 (I found a python bug about this
somewhere).
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Previously folderfilters had to match both the local AND remote
name which caused unwanted behavior in combination with nametrans
rules. Make it operate on the untranslated remote names now and
clarify in the command line option help text.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>