Skip to content

πŸ›‘οΈ Preserve and restore the previous PDF handler - #67

Merged
JFWooten4 merged 7 commits into
mainfrom
restore-pdf-association
Oct 27, 2026
Merged

JFWooten4 merged 7 commits into
mainfrom
restore-pdf-association

Conversation

@JFWooten4

Copy link
Copy Markdown
Member

Summary

Implement opener-0116, checklist Β§2.4 β€” record the previous PDF handler during installation and offer an explicit way to restore it.

  • Add pdf-handler-history.swift with a record command that queries the actual macOS Launch Services PDF association and writes its original bundle ID to previous-pdf-handler.txt only on the first installation. The backup is private (0600), created exclusively and without following symlinks, and is never replaced on reinstallation.
  • Call record immediately before the installer changes the PDF default. If the handler is unknown or saved state is unsafe, fail closed rather than silently losing the user's original default. Do not invent a prior default if the opener was already registered.
  • Add a user-invoked restore command that validates the saved identifier, ensures PDF Magic Opener still owns the PDF association, resolves the installed previous application by bundle ID, verifies its executable and identity, and changes the default only on an explicit restore request. Verify the resulting Launch Services association.
  • Keep the backup available for retry. Never remove or change the separately configured post-scan browser, scanner protections, or user preferences.
  • Document the restore command and warn that restoring another macOS default bypasses the scan gate for ordinary PDF double-clicks.

Tests

test-pdf-handler-history.swift exercises once-only backup, private permissions, protection against symlinks and malformed state, unknown or self-referential original handlers, and fail-closed restoration of missing, altered, or user-replaced PDF handlers. The existing macOS job compiles and runs the new fixtures; the full scanner suite remains unchanged.

Coordination

The existing PDF default read-only lookup (#59) is preserved. Open PR #62 separately verifies the default-setting utility and open PRs #65/#66 cover detecting/optionally restoring PDF Magic Opener itself; this task concerns recording and restoring the previous application and does not replace or duplicate those changes. If the installer opt-in workflow from #66 merges, the record step must remain directly before any opted-in association change rather than recording a declined selection.

Safety

No secret-bearing files are read. The backup includes only a validated bundle identifier, never PDF contents or source paths. All changes are confined to PDF-magic/opener. Do not squash merge unless both scanner-tests and macos-build pass on the integrated head.

JFWooten4 and others added 7 commits October 27, 2026 18:35
Record the original PDF handler exactly once into a private no-follow file and provide an explicit restore action that refuses to override a user-changed default or a missing application.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Test once-only private backup, no overwrite on reinstall, symlink and malformed-state rejection, and exact application verification before restoration.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Deploy the native history helper and capture the existing PDF association once before the installer switches to PDF Magic Opener; fail closed on unsafe state.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Compile the Swift helper and run isolated backup, symlink, validation, and restore regression tests.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Explain secure history storage, explicit restoration, refusal to overwrite newer user defaults, and the security impact of bypassing the opener after restoration.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Evaluate the throwing file read outside Swift's nonthrowing precondition autoclosure without altering production behavior.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
Preserve existing PDF default verification and user-action utilities while keeping backup capture immediately before the installer changes the default association.

Co-authored-by: ChatGPT # 6 <noreply@openai.com>
@JFWooten4
JFWooten4 merged commit e79d56e into main Oct 27, 2026
2 checks passed
@JFWooten4
JFWooten4 deleted the restore-pdf-association branch October 27, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant