diff options
| author | Barry Warsaw | 2015-12-20 12:44:06 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-12-20 12:44:06 -0500 |
| commit | bb45766f91ddce5e68ddf0a1fe6fe67d2f93dd60 (patch) | |
| tree | 1eb70a7836fc5e59968c635f65715de91c766c09 /src/mailman/app | |
| parent | d7bc81a6ab97cd00c70da901cb1d04f80f896685 (diff) | |
| download | mailman-bb45766f91ddce5e68ddf0a1fe6fe67d2f93dd60.tar.gz mailman-bb45766f91ddce5e68ddf0a1fe6fe67d2f93dd60.tar.zst mailman-bb45766f91ddce5e68ddf0a1fe6fe67d2f93dd60.zip | |
Diffstat (limited to 'src/mailman/app')
| -rw-r--r-- | src/mailman/app/lifecycle.py | 12 | ||||
| -rw-r--r-- | src/mailman/app/tests/test_lifecycle.py | 10 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/mailman/app/lifecycle.py b/src/mailman/app/lifecycle.py index 140ccab21..2120c12c6 100644 --- a/src/mailman/app/lifecycle.py +++ b/src/mailman/app/lifecycle.py @@ -94,14 +94,12 @@ def create_list(fqdn_listname, owners=None, style_name=None): def remove_list(mlist): """Remove the list and all associated artifacts and subscriptions.""" - fqdn_listname = mlist.fqdn_listname + # Remove the list's data directory, if it exists. + try: + shutil.rmtree(mlist.data_path) + except FileNotFoundError: + pass # Delete the mailing list from the database. getUtility(IListManager).delete(mlist) # Do the MTA-specific list deletion tasks call_name(config.mta.incoming).delete(mlist) - # Remove the list directory, if it exists. - try: - shutil.rmtree(os.path.join(config.LIST_DATA_DIR, fqdn_listname)) - except OSError as error: - if error.errno != errno.ENOENT: - raise diff --git a/src/mailman/app/tests/test_lifecycle.py b/src/mailman/app/tests/test_lifecycle.py index 62cbbf768..df2bf5233 100644 --- a/src/mailman/app/tests/test_lifecycle.py +++ b/src/mailman/app/tests/test_lifecycle.py @@ -26,7 +26,6 @@ import os import shutil import unittest -from mailman.config import config from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.domain import BadDomainSpecificationError from mailman.app.lifecycle import create_list, remove_list @@ -47,13 +46,12 @@ class TestLifecycle(unittest.TestCase): def test_unregistered_domain(self): # Creating a list with an unregistered domain raises an exception. self.assertRaises(BadDomainSpecificationError, - create_list, 'test@nodomain.example.org') + create_list, 'test@nodomain.example.org') def test_remove_list_error(self): # An error occurs while deleting the list's data directory. mlist = create_list('test@example.com') - data_dir = os.path.join(config.LIST_DATA_DIR, mlist.fqdn_listname) - os.chmod(data_dir, 0) - self.addCleanup(shutil.rmtree, data_dir) + os.chmod(mlist.data_path, 0) + self.addCleanup(shutil.rmtree, mlist.data_path) self.assertRaises(OSError, remove_list, mlist) - os.chmod(data_dir, 0o777) + os.chmod(mlist.data_path, 0o777) |
