gh-66515: Fix locking of an MH mailbox without ".mh_sequences" file (GH-113482)

Guarantee that it either open an existing ".mh_sequences" file or create
a new ".mh_sequences" file, but do not replace existing ".mh_sequences"
file.
This commit is contained in:
Serhiy Storchaka 2024-01-10 15:31:55 +02:00 committed by GitHub
parent 89cee94b31
commit be5e65fdf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -1360,6 +1360,15 @@ class TestMH(TestMailbox, unittest.TestCase):
box.set_sequences({})
self.assertEqual(os.listdir(path), ['.mh_sequences'])
def test_lock_unlock_no_dot_mh_sequences_file(self):
path = os.path.join(self._path, 'foo.bar')
os.mkdir(path)
box = self._factory(path)
self.assertEqual(os.listdir(path), [])
box.lock()
box.unlock()
self.assertEqual(os.listdir(path), ['.mh_sequences'])
def test_issue2625(self):
msg0 = mailbox.MHMessage(self._template % 0)
msg0.add_sequence('foo')