Skip to content

Commit 2e65c98

Browse files
abrichrclaude
andauthored
fix: search all LibreOffice profile dirs for recovery cleanup (#112)
* fix: remove stale health-gate args and add done-gate passthrough in core4_eval.py The core4_eval.py was passing --transport-error-threshold, --health-samples, --health-min-success, and --health-sample-delay to run_dc_eval.py, but those args don't exist in run_dc_eval.py (they were from uncommitted Codex changes). Also adds --done-gate passthrough to match PR #110. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: search all LibreOffice profile dirs for recovery cleanup The cleanup script only targeted LibreOffice/4/user/backup, but LibreOffice 26.2 also uses LibreOffice/user/backup. Now scans all subdirectories under AppData/Roaming/LibreOffice for user profiles. Also clears .~lock.* files that can block file re-opening, and removes lock files from common download locations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 38f8e33 commit 2e65c98

1 file changed

Lines changed: 75 additions & 53 deletions

File tree

  • openadapt_evals/adapters/waa

openadapt_evals/adapters/waa/live.py

Lines changed: 75 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -257,62 +257,84 @@ def _build_type_commands(text: str) -> str:
257257

258258

259259
_LIBREOFFICE_RECOVERY_CLEANUP_SCRIPT = r"""
260-
import os, re, shutil
260+
import os, re, shutil, glob
261261
262262
home = os.path.expanduser("~")
263-
lo_user = os.path.join(home, "AppData", "Roaming", "LibreOffice", "4", "user")
264-
265-
backup_dir = os.path.join(lo_user, "backup")
266-
if os.path.exists(backup_dir):
267-
files = os.listdir(backup_dir)
268-
if files:
269-
shutil.rmtree(backup_dir)
270-
os.makedirs(backup_dir)
271-
print(f"Cleared {len(files)} backup file(s)")
272-
else:
273-
print("Backup dir empty")
274-
else:
275-
print("No backup dir")
276-
277-
xcu = os.path.join(lo_user, "registrymodifications.xcu")
278-
if os.path.exists(xcu):
279-
with open(xcu, "r", encoding="utf-8") as f:
280-
content = f.read()
281-
changed = False
282-
if "RecoveryList" in content:
283-
content = re.sub(
284-
r'<item oor:path="/org.openoffice.Office.Recovery/RecoveryList">.*?</item>',
285-
"",
286-
content,
287-
flags=re.DOTALL,
288-
)
289-
changed = True
290-
print("Removed RecoveryList entries")
291-
autosave_line = (
292-
'<item oor:path="/org.openoffice.Office.Recovery/AutoSave">'
293-
'<prop oor:name="Enabled" oor:op="fuse"><value>false</value></prop></item>'
294-
)
295-
if "AutoSave" not in content:
296-
content = content.replace("</oor:items>", autosave_line + "\n</oor:items>")
297-
changed = True
298-
print("Added AutoSave=false")
299-
elif ">true<" in content.split("AutoSave")[1].split("</item>")[0]:
300-
content = re.sub(
301-
r'<item oor:path="/org.openoffice.Office.Recovery/AutoSave">.*?</item>',
302-
autosave_line,
303-
content,
304-
flags=re.DOTALL,
263+
lo_base = os.path.join(home, "AppData", "Roaming", "LibreOffice")
264+
265+
# Search ALL profile paths: LibreOffice/4/user, LibreOffice/user, etc.
266+
user_dirs = []
267+
if os.path.isdir(lo_base):
268+
for entry in os.listdir(lo_base):
269+
candidate = os.path.join(lo_base, entry, "user")
270+
if os.path.isdir(candidate):
271+
user_dirs.append(candidate)
272+
# Also check LibreOffice/user directly
273+
direct = os.path.join(lo_base, "user")
274+
if os.path.isdir(direct) and direct not in user_dirs:
275+
user_dirs.append(direct)
276+
277+
if not user_dirs:
278+
print(f"No LibreOffice user dirs found under {lo_base}")
279+
280+
for lo_user in user_dirs:
281+
print(f"Cleaning {lo_user}")
282+
283+
# Clear backup directory
284+
backup_dir = os.path.join(lo_user, "backup")
285+
if os.path.exists(backup_dir):
286+
files = os.listdir(backup_dir)
287+
if files:
288+
shutil.rmtree(backup_dir)
289+
os.makedirs(backup_dir)
290+
print(f" Cleared {len(files)} backup file(s)")
291+
292+
# Clear .~lock.* files that block re-opening
293+
for lockfile in glob.glob(os.path.join(lo_user, ".~lock.*")):
294+
os.remove(lockfile)
295+
print(f" Removed lock file: {os.path.basename(lockfile)}")
296+
297+
# Edit registrymodifications.xcu to remove recovery entries and disable autosave
298+
xcu = os.path.join(lo_user, "registrymodifications.xcu")
299+
if os.path.exists(xcu):
300+
with open(xcu, "r", encoding="utf-8") as f:
301+
content = f.read()
302+
changed = False
303+
if "RecoveryList" in content:
304+
content = re.sub(
305+
r'<item oor:path="/org.openoffice.Office.Recovery/RecoveryList">.*?</item>',
306+
"",
307+
content,
308+
flags=re.DOTALL,
309+
)
310+
changed = True
311+
print(" Removed RecoveryList entries")
312+
autosave_line = (
313+
'<item oor:path="/org.openoffice.Office.Recovery/AutoSave">'
314+
'<prop oor:name="Enabled" oor:op="fuse"><value>false</value></prop></item>'
305315
)
306-
changed = True
307-
print("Changed AutoSave to false")
308-
else:
309-
print("AutoSave already disabled")
310-
if changed:
311-
with open(xcu, "w", encoding="utf-8") as f:
312-
f.write(content)
313-
print("Updated registrymodifications.xcu")
314-
else:
315-
print(f"No xcu found at {xcu}")
316+
if "AutoSave" not in content:
317+
content = content.replace("</oor:items>", autosave_line + "\n</oor:items>")
318+
changed = True
319+
print(" Added AutoSave=false")
320+
elif ">true<" in content.split("AutoSave")[1].split("</item>")[0]:
321+
content = re.sub(
322+
r'<item oor:path="/org.openoffice.Office.Recovery/AutoSave">.*?</item>',
323+
autosave_line,
324+
content,
325+
flags=re.DOTALL,
326+
)
327+
changed = True
328+
print(" Changed AutoSave to false")
329+
if changed:
330+
with open(xcu, "w", encoding="utf-8") as f:
331+
f.write(content)
332+
333+
# Also clear lock files from common download locations
334+
for d in [os.path.join(home, "Downloads"), os.path.join(home, "Documents")]:
335+
for lockfile in glob.glob(os.path.join(d, ".~lock.*")):
336+
os.remove(lockfile)
337+
print(f"Removed download lock: {lockfile}")
316338
"""
317339

318340

0 commit comments

Comments
 (0)