Skip to content

Commit 5fa4fe5

Browse files
committed
fixes
1 parent 07edd5c commit 5fa4fe5

4 files changed

Lines changed: 23 additions & 10 deletions

File tree

r2/r2/lib/db/cassandra_compat.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,12 @@ def __enter__(self):
457457
return self
458458

459459
def __exit__(self, exc_type, exc, tb):
460-
try:
460+
# Only send if the body of the with-block succeeded. If the body
461+
# raised we skip the send (act like a rollback) and let the original
462+
# exception propagate. Any exception raised by send() propagates
463+
# naturally — callers must see write failures.
464+
if exc_type is None:
461465
self.send()
462-
except Exception as e:
463-
import sys
464-
sys.stderr.write(f"CASSANDRA ERROR in Mutator.__exit__: {e}\n")
465-
# don't raise during cleanup
466-
return False
467466

468467
def insert(self, key_or_cf, columns_or_key, ttl_or_columns=None, ttl=None):
469468
# Handle both calling conventions:

scripts/force_create_revs.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_args():
1919
p.add_argument('--root', help='Repository root (defaults to parent of scripts dir)')
2020
p.add_argument('--dry-run', action='store_true', help="Don't write; only show what would be done")
2121
p.add_argument('--force', action='store_true', help='Allow destructive writes')
22-
return p.parse_args()
22+
return p.parse_known_args()[0]
2323

2424

2525
def main():
@@ -56,11 +56,23 @@ def main():
5656
continue
5757

5858
try:
59-
wr = WikiRevision.create(wp._id, content, author=system_user, reason='Import from docs/policies')
59+
wr = WikiRevision.create(wp._id, content, author=system_user._id36, reason='Import from docs/policies')
6060
print('Created revision', getattr(wr, '_id', None))
61+
# Update the WikiPage to point at the new revision so that
62+
# revise() won't skip it next time due to stale content.
63+
wp.content = content
64+
wp.revision = str(wr._id)
65+
wp.last_edit_by = system_user._id36
66+
wp._commit()
67+
print('Updated WikiPage', wiki_name)
6168
except Exception as e:
69+
import traceback
70+
traceback.print_exc()
6271
print('Failed create for', wiki_name, e)
6372

6473

6574
if __name__ == '__main__':
6675
main()
76+
else:
77+
# When loaded via tippr-run or paster run, execute main automatically
78+
main()

scripts/force_revise_policies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ def main():
5959

6060
if __name__ == '__main__':
6161
main()
62+
else:
63+
main()
6264

scripts/init_policy_wiki_pages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def ensure_vault(name, author):
199199
if force:
200200
print(f" Wiki page exists; --force given, attempting update...")
201201
try:
202-
existing_page.revise(content, author=system_user, reason="Updated from docs/policies/")
202+
existing_page.revise(content, author=system_user._id36, reason="Updated from docs/policies/")
203203
print(f" SUCCESS: Updated {display_name}\n")
204204
except Exception as e:
205205
print(f" ERROR: Failed to revise existing page '{wiki_name}': {e}")
@@ -221,7 +221,7 @@ def ensure_vault(name, author):
221221
print(f" DEBUG: Frontpage name: '{getattr(Frontpage, 'name', 'N/A')}'")
222222

223223
wp = WikiPage.create(Frontpage, wiki_name)
224-
wp.revise(content, author=system_user, reason="Initial creation from docs/policies/")
224+
wp.revise(content, author=system_user._id36, reason="Initial creation from docs/policies/")
225225
print(f" SUCCESS: Created {display_name}\n")
226226
except Exception as e:
227227
import traceback

0 commit comments

Comments
 (0)