Skip to content

fix(hub): PSP archive layout, sync status and restore targets - #12

Merged
unveroleone merged 5 commits into
mainfrom
fix/hub-sync-bugs
Nov 9, 2026
Merged

unveroleone merged 5 commits into
mainfrom
fix/hub-sync-bugs

Conversation

@unveroleone

@unveroleone unveroleone commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Fixes a set of sync bugs in Save Sync Hub found in an audit and confirmed by a second reviewer.

Data and restore

  • Single-slot PSP saves were zipped without their slot folder, so a restore put PARAM.SFO and DATA.BIN loose into SAVEDATA/, and the Vita's Cloud tab could not restore them at all. Uploads now keep the folder, the same layout and content hash the Vita uses. Archives already uploaded in the old layout restore into the folder named by their SAVEDATA_DIRECTORY, and only when that folder belongs to the same game.
  • Cloud tab restore always extracted into the first source folder, so a RetroArch save could land in PSP SAVEDATA (or in a folder literally called Not found). The target is now picked by platform, and native Vita saves are refused.
  • Downloads are checked against the server's X-Save-Hash before anything is extracted.
  • Server: two uploads within the same second overwrote an older version, because version files are named after a whole-second client timestamp. A numeric suffix is added when the name is taken.

Sync status

  • "Upload needed" never appeared after a local change while the cloud was unchanged, because the local change was silently adopted as synced.
  • Restoring a cloud-only save showed it as a conflict, since no manifest entry was created.
  • The list rescans after a restore.

App behavior

  • Saving server settings wiped the configured sources from config.json.
  • All commands ran on the main thread, so the window froze during scans, uploads and downloads. They now run on the async runtime, with a lock serializing manifest writes.
  • HTTP errors now show the server's message (ureq 2 returns 4xx/5xx as errors, so the old status checks never ran).
  • Temp zips are removed on failures, folder names with multi-byte characters no longer panic the scan, and the multipart filename is sanitized.
  • Removed the unused fs and http plugin permissions from the webview.

Testing

  • cargo check is clean, the frontend builds, and svelte-check reports the same 8 pre-existing errors as main.
  • The archive helpers and API client were run against a local server: legacy flat zip detection and SAVEDATA_DIRECTORY lookup, wrapped uploads, hash-verified download, the 404 and 401 messages, and three same-second uploads keeping both older versions.
  • Not clicked through in the app UI yet.

Not included

  • CSP is still null.
  • The local change-detection hash still ignores file names; changing it would mark every existing save as changed.
  • The Vita still cannot restore legacy flat PSP zips from its Cloud tab. Re-uploading the save from the fixed Hub repairs it.

Rotated archives were named after the client timestamp, which has whole
seconds only, so a second upload in the same second overwrote the older
version. Add a numeric suffix when the name is taken.
The frontend only uses the dialog plugin; all file and network access
runs in Rust. Granting the webview read/write/remove under $HOME and
arbitrary HTTP was unnecessary.
- Saving server settings sent a config without sources, which wiped the
  configured source list from config.json. Read-modify-write instead.
- Cloud tab restore extracted every save into the first source folder,
  so RetroArch saves landed in PSP SAVEDATA (or a literal "Not found"
  folder). Pick the source by the save's platform and refuse native Vita
  saves.
- Rescan after a restore so the status updates right away.
- Single-slot PSP saves were zipped without their slot folder and then
  extracted loose into SAVEDATA. They now keep the folder, matching the
  Vita app (which could not restore the old layout at all) and its
  content hash. Old flat archives restore into the folder named by
  their PARAM.SFO SAVEDATA_DIRECTORY.
- correct_sync_refs adopted any local change as synced while the cloud
  was unchanged, so "upload needed" never appeared. It now only fills
  in a missing reference after a restore.
- Restoring a cloud-only save left no manifest entry, so it showed as
  a conflict. The entry is created from the served hash.
- Commands ran on the main thread and froze the window during network
  and zip work. They run on the async runtime now, with the config
  cloned out of its mutex and a lock serializing manifest writers.
- ureq returns 4xx/5xx as errors, so status branches were dead and
  error bodies were lost. Map them explicitly; 404 gets its message.
- Verify downloads against X-Save-Hash before extracting.
- Temp zips are removed on error paths too.
- psp_title_prefix no longer panics on multi-byte folder names.
- Sanitize the multipart filename.
…heck

- A panic while holding the sync or config lock made every later
  command fail until restart. Both guard data that stays consistent, so
  recover the guard instead.
- A legacy flat PSP archive is only placed into its SAVEDATA_DIRECTORY
  folder when that folder belongs to the same game id.
@unveroleone
unveroleone merged commit e6bcf45 into main Nov 9, 2026
@unveroleone
unveroleone deleted the fix/hub-sync-bugs branch November 9, 2026 18:35
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