2020-11-01 08:43:16 +01:00
|
|
|
"""
|
|
|
|
Maildir repository support
|
2002-06-19 08:08:59 +02:00
|
|
|
|
2020-11-01 08:43:16 +01:00
|
|
|
Copyright (C) 2002-2015 John Goerzen & contributors
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
"""
|
2020-08-29 21:10:16 +02:00
|
|
|
import os
|
2011-03-11 22:13:21 +01:00
|
|
|
from offlineimap import folder
|
2011-01-05 17:00:56 +01:00
|
|
|
from offlineimap.ui import getglobalui
|
2011-08-29 15:33:58 +02:00
|
|
|
from offlineimap.error import OfflineImapError
|
2012-02-05 11:57:19 +01:00
|
|
|
from offlineimap.repository.Base import BaseRepository
|
2002-06-19 08:08:59 +02:00
|
|
|
|
2020-08-29 19:53:38 +02:00
|
|
|
|
2002-06-19 08:08:59 +02:00
|
|
|
class MaildirRepository(BaseRepository):
|
2020-11-01 09:21:08 +01:00
|
|
|
"""
|
|
|
|
Maildir Repository Class
|
|
|
|
"""
|
2003-04-18 04:18:34 +02:00
|
|
|
def __init__(self, reposname, account):
|
2002-06-19 08:08:59 +02:00
|
|
|
"""Initialize a MaildirRepository object. Takes a path name
|
|
|
|
to the directory holding all the Maildir directories."""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
BaseRepository.__init__(self, reposname, account)
|
2002-06-19 08:08:59 +02:00
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
self.root = self.getlocalroot()
|
2002-06-19 08:08:59 +02:00
|
|
|
self.folders = None
|
2011-01-05 17:00:56 +01:00
|
|
|
self.ui = getglobalui()
|
2020-11-01 09:29:31 +01:00
|
|
|
self.debug("MaildirRepository initialized, sep is %s" %
|
|
|
|
repr(self.getsep()))
|
2011-08-16 10:55:13 +02:00
|
|
|
self.folder_atimes = []
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
|
2008-03-27 22:19:35 +01:00
|
|
|
# Create the top-level folder if it doesn't exist
|
|
|
|
if not os.path.isdir(self.root):
|
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 18:25:27 +02:00
|
|
|
os.makedirs(self.root, 0o700)
|
2008-03-27 22:19:35 +01:00
|
|
|
|
2015-11-20 20:09:09 +01:00
|
|
|
# Create the keyword->char mapping
|
|
|
|
self.keyword2char = dict()
|
2020-11-01 09:26:42 +01:00
|
|
|
for char in 'abcdefghijklmnopqrstuvwxyz':
|
|
|
|
confkey = 'customflag_' + char
|
2015-11-20 20:09:09 +01:00
|
|
|
keyword = self.getconf(confkey, None)
|
|
|
|
if keyword is not None:
|
2020-11-01 09:26:42 +01:00
|
|
|
self.keyword2char[keyword] = char
|
2015-11-20 20:09:09 +01:00
|
|
|
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
def _append_folder_atimes(self, foldername):
|
2011-09-15 15:06:30 +02:00
|
|
|
"""Store the atimes of a folder's new|cur in self.folder_atimes"""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2020-11-01 09:26:42 +01:00
|
|
|
path = os.path.join(self.root, foldername)
|
|
|
|
new = os.path.join(path, 'new')
|
|
|
|
cur = os.path.join(path, 'cur')
|
|
|
|
atimes = (path, os.path.getatime(new), os.path.getatime(cur))
|
2011-09-15 15:06:31 +02:00
|
|
|
self.folder_atimes.append(atimes)
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
|
2011-09-15 15:06:30 +02:00
|
|
|
def restore_atime(self):
|
|
|
|
"""Sets folders' atime back to their values after a sync
|
|
|
|
|
|
|
|
Controlled by the 'restoreatime' config parameter."""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2011-09-15 15:06:30 +02:00
|
|
|
if not self.getconfboolean('restoreatime', False):
|
2020-08-29 19:53:38 +02:00
|
|
|
return # not configured to restore
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
|
2011-09-15 15:06:31 +02:00
|
|
|
for (dirpath, new_atime, cur_atime) in self.folder_atimes:
|
|
|
|
new_dir = os.path.join(dirpath, 'new')
|
|
|
|
cur_dir = os.path.join(dirpath, 'cur')
|
|
|
|
os.utime(new_dir, (new_atime, os.path.getmtime(new_dir)))
|
|
|
|
os.utime(cur_dir, (cur_atime, os.path.getmtime(cur_dir)))
|
2002-08-08 22:15:30 +02:00
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
def getlocalroot(self):
|
2016-11-30 18:42:53 +01:00
|
|
|
xforms = [os.path.expanduser, os.path.expandvars]
|
2014-11-02 09:14:42 +01:00
|
|
|
return self.getconf_xform('localfolders', xforms)
|
2003-04-18 04:18:34 +02:00
|
|
|
|
2002-08-08 22:15:30 +02:00
|
|
|
def debug(self, msg):
|
2020-11-01 09:21:08 +01:00
|
|
|
"""
|
|
|
|
Debug function for the message. It calls the ui.debug function and
|
|
|
|
prepends the string 'maildir'.
|
|
|
|
Args:
|
|
|
|
msg: Message to send to the debug
|
|
|
|
|
|
|
|
Returns: None
|
|
|
|
|
|
|
|
"""
|
2002-08-08 22:15:30 +02:00
|
|
|
self.ui.debug('maildir', msg)
|
2002-06-19 08:08:59 +02:00
|
|
|
|
2002-06-19 08:16:19 +02:00
|
|
|
def getsep(self):
|
2003-04-18 04:18:34 +02:00
|
|
|
return self.getconf('sep', '.').strip()
|
2002-06-20 04:55:24 +02:00
|
|
|
|
2015-11-20 20:09:09 +01:00
|
|
|
def getkeywordmap(self):
|
2015-11-22 19:52:32 +01:00
|
|
|
return self.keyword2char if len(self.keyword2char) > 0 else None
|
2015-11-20 20:09:09 +01:00
|
|
|
|
2002-06-20 04:55:24 +02:00
|
|
|
def makefolder(self, foldername):
|
2011-06-06 11:37:25 +02:00
|
|
|
"""Create new Maildir folder if necessary
|
|
|
|
|
2011-09-30 08:58:08 +02:00
|
|
|
This will not update the list cached in getfolders(). You will
|
|
|
|
need to invoke :meth:`forgetfolders` to force new caching when
|
|
|
|
you are done creating folders yourself.
|
|
|
|
|
2011-06-06 11:37:25 +02:00
|
|
|
:param foldername: A relative mailbox name. The maildir will be
|
|
|
|
created in self.root+'/'+foldername. All intermediate folder
|
|
|
|
levels will be created if they do not exist yet. 'cur',
|
|
|
|
'tmp', and 'new' subfolders will be created in the maildir.
|
|
|
|
"""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2011-09-15 15:37:52 +02:00
|
|
|
self.ui.makefolder(self, foldername)
|
|
|
|
if self.account.dryrun:
|
|
|
|
return
|
2011-06-06 11:37:25 +02:00
|
|
|
full_path = os.path.abspath(os.path.join(self.root, foldername))
|
2013-07-21 21:00:23 +02:00
|
|
|
|
2011-06-06 11:37:25 +02:00
|
|
|
# sanity tests
|
2002-08-08 04:41:52 +02:00
|
|
|
if self.getsep() == '/':
|
2011-06-06 11:37:25 +02:00
|
|
|
for component in foldername.split('/'):
|
2020-08-30 14:25:55 +02:00
|
|
|
assert component not in ['new', 'cur', 'tmp'], \
|
2020-08-29 19:53:38 +02:00
|
|
|
"When using nested folders (/ as a Maildir separator), " \
|
2011-06-06 11:37:25 +02:00
|
|
|
"folder names may not contain 'new', 'cur', 'tmp'."
|
2020-11-01 09:29:31 +01:00
|
|
|
assert foldername.find('../') == -1, \
|
|
|
|
"Folder names may not contain ../"
|
|
|
|
assert not foldername.startswith('/'), \
|
|
|
|
"Folder names may not begin with /"
|
2002-08-08 05:01:31 +02:00
|
|
|
|
2011-06-06 11:37:25 +02:00
|
|
|
# If we're using hierarchical folders, it's possible that
|
|
|
|
# sub-folders may be created before higher-up ones.
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug("makefolder: calling makedirs '%s'" % full_path)
|
2011-06-06 11:37:25 +02:00
|
|
|
try:
|
2012-02-05 11:31:54 +01:00
|
|
|
os.makedirs(full_path, 0o700)
|
2020-11-01 09:26:42 +01:00
|
|
|
except OSError as exc:
|
|
|
|
if exc.errno == 17 and os.path.isdir(full_path):
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug("makefolder: '%s' already a directory" % foldername)
|
2011-06-06 11:37:25 +02:00
|
|
|
else:
|
|
|
|
raise
|
2002-06-20 04:55:24 +02:00
|
|
|
for subdir in ['cur', 'new', 'tmp']:
|
2011-06-06 11:37:25 +02:00
|
|
|
try:
|
2012-02-05 11:31:54 +01:00
|
|
|
os.mkdir(os.path.join(full_path, subdir), 0o700)
|
2020-11-01 09:26:42 +01:00
|
|
|
except OSError as exc:
|
|
|
|
if exc.errno == 17 and os.path.isdir(full_path):
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug("makefolder: '%s' already has subdir %s" %
|
|
|
|
(foldername, subdir))
|
2011-06-06 11:37:25 +02:00
|
|
|
else:
|
|
|
|
raise
|
2002-06-20 04:55:24 +02:00
|
|
|
|
|
|
|
def deletefolder(self, foldername):
|
2020-08-29 19:53:38 +02:00
|
|
|
self.ui.warn("NOT YET IMPLEMENTED: DELETE FOLDER %s" % foldername)
|
2002-06-20 04:55:24 +02:00
|
|
|
|
|
|
|
def getfolder(self, foldername):
|
2011-08-29 15:33:58 +02:00
|
|
|
"""Return a Folder instance of this Maildir
|
|
|
|
|
|
|
|
If necessary, scan and cache all foldernames to make sure that
|
|
|
|
we only return existing folders and that 2 calls with the same
|
|
|
|
name will return the same object."""
|
2015-01-08 17:13:33 +01:00
|
|
|
|
2011-08-29 15:33:58 +02:00
|
|
|
# getfolders() will scan and cache the values *if* necessary
|
|
|
|
folders = self.getfolders()
|
2020-11-01 09:26:42 +01:00
|
|
|
for foldr in folders:
|
|
|
|
if foldername == foldr.name:
|
|
|
|
return foldr
|
2011-08-29 15:33:58 +02:00
|
|
|
raise OfflineImapError("getfolder() asked for a nonexisting "
|
2020-11-01 09:29:31 +01:00
|
|
|
"folder '%s'." % foldername,
|
|
|
|
OfflineImapError.ERROR.FOLDER)
|
2011-08-29 15:33:58 +02:00
|
|
|
|
2015-01-01 21:41:11 +01:00
|
|
|
def _getfolders_scandir(self, root, extension=None):
|
2011-06-16 17:09:29 +02:00
|
|
|
"""Recursively scan folder 'root'; return a list of MailDirFolder
|
|
|
|
|
|
|
|
:param root: (absolute) path to Maildir root
|
|
|
|
:param extension: (relative) subfolder to examine within root"""
|
2015-01-08 17:13:33 +01:00
|
|
|
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug("_GETFOLDERS_SCANDIR STARTING. root = %s, extension = %s" %
|
2015-01-08 17:13:33 +01:00
|
|
|
(root, extension))
|
2002-06-19 08:08:59 +02:00
|
|
|
retval = []
|
2002-08-08 04:57:52 +02:00
|
|
|
|
|
|
|
# Configure the full path to this repository -- "toppath"
|
2011-06-16 17:09:29 +02:00
|
|
|
if extension:
|
2002-08-08 04:57:52 +02:00
|
|
|
toppath = os.path.join(root, extension)
|
2011-06-16 17:09:29 +02:00
|
|
|
else:
|
|
|
|
toppath = root
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug(" toppath = %s" % toppath)
|
2002-08-08 22:15:30 +02:00
|
|
|
|
2011-06-06 11:37:25 +02:00
|
|
|
# Iterate over directories in top & top itself.
|
2011-09-19 14:14:44 +02:00
|
|
|
for dirname in os.listdir(toppath) + ['']:
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug(" dirname = %s" % dirname)
|
Folder could not be created
On Tue, Dec 13, 2011 at 12:00:57PM -0500, W. Trevor King wrote:
> I've attached a patch that does fix the problem…
Oops, *now* I've attached the patch and logs ;).
--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
From 3067b1b4dfb00d165bd9480ea49f446adb12991d Mon Sep 17 00:00:00 2001
From: W. Trevor King <wking@drexel.edu>
Date: Tue, 13 Dec 2011 11:26:00 -0500
Subject: [PATCH] Only scan children in _getfolders_scandir if extension is set.
When sep is '/', MaildirRepository._getfolders_scandir recursively
checks sub-directories for additional maildirs. The old loop logic
always checked the top directory and its children. This lead to
children being found twice, once from their parent, with dirname
matching their directory name, and once from themselves, with a
dirname of ''.
This patch fixes the problem by only checking the top directory when
extension is not set (i.e. for the root directory).
2011-12-13 18:04:19 +01:00
|
|
|
if dirname == '' and extension is not None:
|
2012-01-07 23:26:02 +01:00
|
|
|
self.debug(' skip this entry (already scanned)')
|
Folder could not be created
On Tue, Dec 13, 2011 at 12:00:57PM -0500, W. Trevor King wrote:
> I've attached a patch that does fix the problem…
Oops, *now* I've attached the patch and logs ;).
--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
From 3067b1b4dfb00d165bd9480ea49f446adb12991d Mon Sep 17 00:00:00 2001
From: W. Trevor King <wking@drexel.edu>
Date: Tue, 13 Dec 2011 11:26:00 -0500
Subject: [PATCH] Only scan children in _getfolders_scandir if extension is set.
When sep is '/', MaildirRepository._getfolders_scandir recursively
checks sub-directories for additional maildirs. The old loop logic
always checked the top directory and its children. This lead to
children being found twice, once from their parent, with dirname
matching their directory name, and once from themselves, with a
dirname of ''.
This patch fixes the problem by only checking the top directory when
extension is not set (i.e. for the root directory).
2011-12-13 18:04:19 +01:00
|
|
|
continue
|
2011-06-06 11:37:25 +02:00
|
|
|
if dirname in ['cur', 'new', 'tmp']:
|
2012-01-07 23:26:02 +01:00
|
|
|
self.debug(" skip this entry (Maildir special)")
|
2002-08-08 04:57:52 +02:00
|
|
|
# Bypass special files.
|
|
|
|
continue
|
|
|
|
fullname = os.path.join(toppath, dirname)
|
2002-06-19 08:08:59 +02:00
|
|
|
if not os.path.isdir(fullname):
|
2012-01-07 23:26:02 +01:00
|
|
|
self.debug(" skip this entry (not a directory)")
|
2002-08-08 04:57:52 +02:00
|
|
|
# Not a directory -- not a folder.
|
2002-06-19 08:08:59 +02:00
|
|
|
continue
|
2015-01-13 13:59:52 +01:00
|
|
|
# extension can be None.
|
2012-01-07 23:26:02 +01:00
|
|
|
if extension:
|
2002-08-09 03:53:57 +02:00
|
|
|
foldername = os.path.join(extension, dirname)
|
2012-01-07 23:26:02 +01:00
|
|
|
else:
|
|
|
|
foldername = dirname
|
|
|
|
|
2002-08-09 03:53:05 +02:00
|
|
|
if (os.path.isdir(os.path.join(fullname, 'cur')) and
|
2020-08-29 19:53:38 +02:00
|
|
|
os.path.isdir(os.path.join(fullname, 'new')) and
|
|
|
|
os.path.isdir(os.path.join(fullname, 'tmp'))):
|
2002-08-09 03:53:05 +02:00
|
|
|
# This directory has maildir stuff -- process
|
2020-08-29 19:53:38 +02:00
|
|
|
self.debug(" This is maildir folder '%s'." % foldername)
|
2011-08-29 15:33:58 +02:00
|
|
|
if self.getconfboolean('restoreatime', False):
|
2011-08-16 10:55:13 +02:00
|
|
|
self._append_folder_atimes(foldername)
|
2020-11-01 09:26:42 +01:00
|
|
|
file_desc = self.getfoldertype()(self.root, foldername,
|
|
|
|
self.getsep(), self)
|
|
|
|
retval.append(file_desc)
|
2011-08-29 15:09:16 +02:00
|
|
|
|
2011-09-19 14:14:44 +02:00
|
|
|
if self.getsep() == '/' and dirname != '':
|
2011-06-16 17:09:29 +02:00
|
|
|
# Recursively check sub-directories for folders too.
|
2002-08-08 05:27:55 +02:00
|
|
|
retval.extend(self._getfolders_scandir(root, foldername))
|
2020-11-01 09:29:31 +01:00
|
|
|
self.debug("_GETFOLDERS_SCANDIR RETURNING %s" %
|
|
|
|
repr([x.getname() for x in retval]))
|
2002-06-19 08:08:59 +02:00
|
|
|
return retval
|
2011-12-01 17:01:43 +01:00
|
|
|
|
2002-08-08 04:57:52 +02:00
|
|
|
def getfolders(self):
|
2020-08-30 11:03:57 +02:00
|
|
|
if self.folders is None:
|
2002-08-08 04:57:52 +02:00
|
|
|
self.folders = self._getfolders_scandir(self.root)
|
|
|
|
return self.folders
|
2012-01-05 14:18:29 +01:00
|
|
|
|
2012-10-16 20:20:35 +02:00
|
|
|
def getfoldertype(self):
|
2020-11-01 09:21:08 +01:00
|
|
|
"""
|
|
|
|
Returns a folder MaildirFolder type.
|
|
|
|
|
|
|
|
Returns: A MaildirFolder class
|
|
|
|
|
|
|
|
"""
|
2012-10-16 20:20:35 +02:00
|
|
|
return folder.Maildir.MaildirFolder
|
|
|
|
|
2012-01-05 14:18:29 +01:00
|
|
|
def forgetfolders(self):
|
|
|
|
"""Forgets the cached list of folders, if any. Useful to run
|
|
|
|
after a sync run."""
|
2015-01-01 21:41:11 +01:00
|
|
|
|
2012-01-05 14:18:29 +01:00
|
|
|
self.folders = None
|