Skip to content

Connections and folders are lost after macOS reboot unless SQLite WAL is manually checkpointed #29

Description

@yowainaegi

Summary

macSCP saves connections into SwiftData/SQLite, but after rebooting macOS the saved connections disappear from the UI and from the ZCONNECTIONENTITY table.

I confirmed that the data is written before reboot, but it appears to remain in the SQLite WAL file. If I manually run PRAGMA wal_checkpoint(FULL); before rebooting, the data survives the reboot.

Environment

  • OS: macOS Sequoia 15.7.7
  • Storage observed at:
~/Library/Application Support/default.store
~/Library/Application Support/default.store-wal
~/Library/Application Support/default.store-shm

Steps to Reproduce

  1. Open macSCP.
  2. Create a new connection, for example checkpoint-test.
  3. Confirm the connection exists:
sqlite3 ~/Library/Application\ Support/default.store \
  "select ZNAME,ZHOST,ZUSERNAME from ZCONNECTIONENTITY;"
  1. Reboot macOS without manually checkpointing.
  2. After login, before opening macSCP, run:
sqlite3 ~/Library/Application\ Support/default.store \
  "select ZNAME,ZHOST,ZUSERNAME from ZCONNECTIONENTITY;"

Actual Result

The connection table is empty after reboot, and macSCP UI shows no saved connections.

Expected Result

Saved connections and folders should persist across macOS reboots.

Additional Findings

Before reboot, the data exists:

sqlite3 ~/Library/Application\ Support/default.store \
  "select ZNAME,ZHOST,ZUSERNAME from ZCONNECTIONENTITY;"

The database files show recent writes in the WAL file:

ls -la ~/Library/Application\ Support/default.store*

Manually checkpointing before reboot prevents data loss:

sqlite3 ~/Library/Application\ Support/default.store \
  "PRAGMA wal_checkpoint(FULL);"

This returned:

0|15|15

After doing this, rebooting macOS preserves the connection.

Suspected Cause

SwiftData appears to be using the default SQLite store path:

~/Library/Application Support/default.store
~/Library/Application Support/default.store-wal
~/Library/Application Support/default.store-shm

The app does not appear to force a checkpoint or otherwise ensure WAL contents are flushed before macOS reboot.

Also, the store path is not app-specific. It should probably be placed under something like:

~/Library/Application Support/macSCP/macSCP.store

Suggested Fix

  • Use an explicit SwiftData store URL under the app's Application Support directory.
  • Migrate existing default.store* files if present.
  • Ensure the model context is saved and the SQLite WAL is checkpointed on app quit / scene phase changes / before termination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions