Skip to content

Commit e290502

Browse files
jonfroehlichclaude
andcommitted
Review follow-ups: pin legacy-base orphan repair, honest dry-run version note
Two items from the PR review: 1. Test the legacy-base branch of repair_diverged_artifact_filenames — the one changed path with no test. An orphan left on disk under the pre-#1404 base (plain and "-<timestamp>"-uniquified) is found and repaired forward to the new-scheme name; without these, dropping the legacy_base half of the scan would silently strand old orphans. 2. The 2.29.0 version description now says this is the dry-run stage (renames inventoried in debug.log, not performed), so the admin dashboard doesn't claim a rename that hasn't happened. The stage-2 commit that removes --dry-run should restore the final wording. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5401477 commit e290502

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

makeabilitylab/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
# Makeability Lab Global Variables, including Makeability Lab version
8989
ML_WEBSITE_VERSION = "2.29.0" # Keep this updated with each release and also change the short description below
90-
ML_WEBSITE_VERSION_DESCRIPTION = "Standardized filenames for talks and posters now end in '_Talk' and '_Poster' (#1404), so a downloaded slide deck or poster is no longer indistinguishable from the paper PDF of the same work. Publication filenames are unchanged. Existing talk/poster files are renamed once, on deploy."
90+
ML_WEBSITE_VERSION_DESCRIPTION = "Standardized filenames for talks and posters now end in '_Talk' and '_Poster' (#1404), so a downloaded slide deck or poster is no longer indistinguishable from the paper PDF of the same work. Publication filenames are unchanged. Dry-run stage: existing files are NOT renamed yet — the pending renames are inventoried in debug.log for review, and the one-time rename ships in the follow-up release."
9191
DATE_MAKEABILITYLAB_FORMED = datetime.date(2012, 1, 1) # Date Makeability Lab was formed
9292
MAX_BANNERS = 7 # Maximum number of banners on a page
9393

website/tests/test_repair_diverged_artifact_filenames.py

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ def setUp(self):
3232
override.enable()
3333
self.addCleanup(override.disable)
3434

35-
def _simulate_divergence(self, talk):
35+
def _simulate_divergence(self, talk, include_type_suffix=True,
36+
name_suffix=""):
3637
"""Reproduce the bug's end state for the pdf_file: move the real file to
3738
the extension-less standardized base (the orphan) and point the DB at a
38-
now-missing old name."""
39+
now-missing old name.
40+
41+
``include_type_suffix=False`` names the orphan under the pre-#1404
42+
scheme (no trailing "_Talk") — what an orphan left behind before that
43+
scheme change looks like. ``name_suffix`` appends a
44+
"-<timestamp>"-style uniqueness suffix to the orphan.
45+
"""
3946
directory = os.path.dirname(talk.pdf_file.path)
40-
valid_base = get_valid_filename(Artifact.generate_filename(talk))
47+
valid_base = get_valid_filename(Artifact.generate_filename(
48+
talk, include_type_suffix=include_type_suffix)) + name_suffix
4149
orphan_path = os.path.join(directory, valid_base) # no extension
4250
os.rename(talk.pdf_file.path, orphan_path)
4351
# DB now references a file that isn't there.
@@ -69,6 +77,51 @@ def test_repairs_pdf_pointing_at_missing_file(self):
6977
self.assertTrue(talk.pdf_file.storage.exists(talk.pdf_file.name))
7078
self.assertFalse(os.path.exists(orphan_path))
7179

80+
def test_repairs_orphan_left_under_the_pre_1404_base(self):
81+
"""The #1390 bug predates the #1404 scheme change, so an orphan it left
82+
behind carries the OLD standardized base (no trailing "_Talk"). The
83+
command must still find it — and repairs it forward to the new-scheme
84+
name."""
85+
alice = self.make_person(first_name="Alice", last_name="Smith")
86+
talk = self.make_talk(
87+
title="A Recoverable Talk", forum_name="CHI", year=2024,
88+
authors=[alice],
89+
)
90+
_, orphan_path = self._simulate_divergence(
91+
talk, include_type_suffix=False)
92+
self.assertTrue(os.path.exists(orphan_path))
93+
94+
call_command("repair_diverged_artifact_filenames")
95+
96+
talk.refresh_from_db()
97+
new_base = get_valid_filename(Artifact.generate_filename(talk))
98+
self.assertEqual(
99+
os.path.basename(talk.pdf_file.name), new_base + ".pdf"
100+
)
101+
self.assertTrue(talk.pdf_file.storage.exists(talk.pdf_file.name))
102+
self.assertFalse(os.path.exists(orphan_path))
103+
104+
def test_repairs_uniquified_orphan_under_the_pre_1404_base(self):
105+
"""Same, for a pre-#1404 orphan whose name collided on disk and picked
106+
up the "-<timestamp>" uniqueness suffix (ensure_filename_is_unique)."""
107+
alice = self.make_person(first_name="Alice", last_name="Smith")
108+
talk = self.make_talk(
109+
title="A Recoverable Talk", forum_name="CHI", year=2024,
110+
authors=[alice],
111+
)
112+
_, orphan_path = self._simulate_divergence(
113+
talk, include_type_suffix=False, name_suffix="-1782399772.42")
114+
115+
call_command("repair_diverged_artifact_filenames")
116+
117+
talk.refresh_from_db()
118+
new_base = get_valid_filename(Artifact.generate_filename(talk))
119+
self.assertEqual(
120+
os.path.basename(talk.pdf_file.name), new_base + ".pdf"
121+
)
122+
self.assertTrue(talk.pdf_file.storage.exists(talk.pdf_file.name))
123+
self.assertFalse(os.path.exists(orphan_path))
124+
72125
def test_dry_run_changes_nothing(self):
73126
alice = self.make_person(first_name="Alice", last_name="Smith")
74127
talk = self.make_talk(

0 commit comments

Comments
 (0)