mirror of
https://git.code.sf.net/p/archivemail/code
synced 2024-12-21 23:32:54 +00:00
Don't create hidden archives when archiving mailboxes with leading dots in the name
When archiving a mailbox with leading dots in the name and no archive name prefix specified, strip the dots off the archive name. This is targeting Maildir++ subfolders.
This commit is contained in:
parent
67f23e1af4
commit
f1f34ca46e
3 changed files with 30 additions and 0 deletions
|
@ -59,6 +59,11 @@ Version 0.8.0 - UNRELEASED
|
|||
strftime(). Specifying this option disables the default archive name
|
||||
suffix. Obsoletes: feature request #604281. (Thanks Serafeim Zanikolas
|
||||
for an initial patch)
|
||||
* When archiving a mailbox with a leading dot in the name and with no archive
|
||||
name prefix specified, archivemail no longer creates hidden archives, but
|
||||
strips the dot off the archive name. In particular, this makes working
|
||||
with Maildir++ subfolders more convenient. Closes: feature request
|
||||
#604281.
|
||||
|
||||
Version 0.7.2 - 9 November 2007
|
||||
|
||||
|
|
|
@ -1649,6 +1649,9 @@ def make_archive_name(mailbox_name):
|
|||
archive_base = mailbox_name.rsplit('/', 1)[-1]
|
||||
else:
|
||||
archive_dir, archive_base = os.path.split(mailbox_name)
|
||||
if not prefix:
|
||||
# Don't create hidden archives, e.g. when processing Maildir++ subfolders
|
||||
archive_base = archive_base.lstrip('.')
|
||||
if options.output_dir:
|
||||
archive_dir = options.output_dir
|
||||
archive_name = os.path.join(archive_dir, prefix + archive_base + suffix)
|
||||
|
|
|
@ -968,6 +968,28 @@ class TestArchiveAffixes(unittest.TestCase):
|
|||
archivemail.options.archive_suffix = None
|
||||
archivemail.options.quiet = False
|
||||
|
||||
class TestArchiveHiddenMbox(unittest.TestCase):
|
||||
def setUp(self):
|
||||
archivemail.options.quiet = True
|
||||
self.mbox = ".upper.lower"
|
||||
|
||||
def testHiddenMbox(self):
|
||||
"""leading dots are stripped from the archive name when no prefix is added"""
|
||||
self.assertEqual(archivemail.make_archive_name(self.mbox),
|
||||
self.mbox.lstrip('.') +
|
||||
archivemail.options.archive_default_suffix)
|
||||
|
||||
def testHiddenMboxPrefixedArchive(self):
|
||||
"""no dots are stripped from the archive name when a prefix is added"""
|
||||
prefix = ".hidden_"
|
||||
archivemail.options.archive_prefix = prefix
|
||||
self.assertEqual(archivemail.make_archive_name(self.mbox),
|
||||
prefix + self.mbox)
|
||||
|
||||
def tearDown(self):
|
||||
archivemail.options.quiet = False
|
||||
archivemail.options.archive_prefix = None
|
||||
|
||||
class TestArchiveDryRun(TestArchive):
|
||||
"""make sure the 'dry-run' option works"""
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in a new issue