summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2015-12-20 13:53:25 -0500
committerBarry Warsaw2015-12-20 13:53:25 -0500
commit573e60947a0a688afccf81bd9230fed9c6bbb650 (patch)
tree095789f39822834197ab9554c82e905e5ca1aaf6 /src
parentbb45766f91ddce5e68ddf0a1fe6fe67d2f93dd60 (diff)
downloadmailman-573e60947a0a688afccf81bd9230fed9c6bbb650.tar.gz
mailman-573e60947a0a688afccf81bd9230fed9c6bbb650.tar.zst
mailman-573e60947a0a688afccf81bd9230fed9c6bbb650.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/app/lifecycle.py2
-rw-r--r--src/mailman/database/alembic/versions/70af5a4e5790_digests.py22
-rw-r--r--src/mailman/database/tests/test_migrations.py23
-rw-r--r--src/mailman/docs/NEWS.rst3
4 files changed, 45 insertions, 5 deletions
diff --git a/src/mailman/app/lifecycle.py b/src/mailman/app/lifecycle.py
index 2120c12c6..0d268fe87 100644
--- a/src/mailman/app/lifecycle.py
+++ b/src/mailman/app/lifecycle.py
@@ -23,8 +23,6 @@ __all__ = [
]
-import os
-import errno
import shutil
import logging
diff --git a/src/mailman/database/alembic/versions/70af5a4e5790_digests.py b/src/mailman/database/alembic/versions/70af5a4e5790_digests.py
index 2b53202d9..9a03678fe 100644
--- a/src/mailman/database/alembic/versions/70af5a4e5790_digests.py
+++ b/src/mailman/database/alembic/versions/70af5a4e5790_digests.py
@@ -10,14 +10,25 @@ Create Date: 2015-12-19 12:05:42.202998
revision = '70af5a4e5790'
down_revision = '47294d3a604'
-from alembic import op
+import os
import sqlalchemy as sa
+from alembic import op
+from mailman.config import config
+
def upgrade():
with op.batch_alter_table('mailinglist') as batch_op:
batch_op.alter_column('digestable', new_column_name='digests_enabled')
batch_op.drop_column('nondigestable')
+ # Non-database migration: rename the list's data-path.
+ for dirname in os.listdir(config.LIST_DATA_DIR):
+ if '@' in dirname:
+ old_name = os.path.join(config.LIST_DATA_DIR, dirname)
+ listname, at, domain = dirname.partition('@')
+ new_name = os.path.join(config.LIST_DATA_DIR,
+ '{}.{}'.format(listname, domain))
+ os.rename(old_name, new_name)
def downgrade():
@@ -25,5 +36,10 @@ def downgrade():
batch_op.alter_column('digests_enabled', new_column_name='digestable')
# The data for this column is lost, it's not used anyway.
batch_op.add_column(sa.Column('nondigestable', sa.Boolean))
-
-# XXX - move list.data_path
+ for dirname in os.listdir(config.LIST_DATA_DIR):
+ if '@' not in dirname:
+ old_name = os.path.join(config.LIST_DATA_DIR, dirname)
+ listname, domain = dirname.split('.', 1)
+ new_name = os.path.join(config.LIST_DATA_DIR,
+ '{}@{}'.format(listname, domain))
+ os.rename(old_name, new_name)
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py
index e3f4b9581..b840842cb 100644
--- a/src/mailman/database/tests/test_migrations.py
+++ b/src/mailman/database/tests/test_migrations.py
@@ -22,10 +22,12 @@ __all__ = [
]
+import os
import unittest
import alembic.command
import sqlalchemy as sa
+from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.database.alembic import alembic_cfg
from mailman.database.helpers import exists_in_db
@@ -196,3 +198,24 @@ class TestMigrations(unittest.TestCase):
results = config.db.store.execute(
'SELECT id, digests_enabled FROM mailinglist').fetchall()
self.assertEqual(results, IDS_TO_DIGESTABLE)
+
+ def test_70af5a4e5790_data_paths(self):
+ # Create a couple of mailing lists through the standard API.
+ with transaction():
+ ant = create_list('ant@example.com')
+ bee = create_list('bee@example.com')
+ # Downgrade and verify that the old data paths exist.
+ alembic.command.downgrade(alembic_cfg, '47294d3a604')
+ self.assertTrue(os.path.exists(
+ os.path.join(config.LIST_DATA_DIR, 'ant@example.com')))
+ self.assertTrue(os.path.exists(
+ os.path.join(config.LIST_DATA_DIR, 'ant@example.com')))
+ # Upgrade and verify that the new data paths exists and the old ones
+ # no longer do.
+ alembic.command.upgrade(alembic_cfg, '70af5a4e5790')
+ self.assertFalse(os.path.exists(
+ os.path.join(config.LIST_DATA_DIR, 'ant@example.com')))
+ self.assertFalse(os.path.exists(
+ os.path.join(config.LIST_DATA_DIR, 'ant@example.com')))
+ self.assertTrue(os.path.exists(ant.data_path))
+ self.assertTrue(os.path.exists(bee.data_path))
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 6e098a8c0..3e8870589 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -135,6 +135,9 @@ Other
* Rework the digest machinery, and add a new `send-digests` subcommand, which
can be used from the command line or cron to immediately send out any
partially collected digests.
+ * The mailing list "data directory" has been renamed. Instead of using the
+ fqdn listname, the subdirectory inside ``[paths]list_data_dir`` now uses
+ the List-ID.
3.0.0 -- "Show Don't Tell"