Collect read settings with settings.Load, which stands the defaults in
for a file that is there but can't be read, or doesn't parse with no
good .bak. A sync then pushed those defaults as "changed here", and
every other computer brought them in over its own theme, language,
text size, allow list and per-model settings; an export carried them
too. Collect now reads through settings.LoadChecked and stops with its
error, as it does for providers.json (9c54a560). The sync ends before
anything is sealed or pushed, and its status shows the error; the CLI
and the GUI's export show it. A missing or empty file is unchanged.
Sibling: library.Collect read any failed stat of library.json as "no
library"; only a missing file is that now, any other error stops the
backup. plugins.json (provider.Carried -> plugin.list) still reads as
no plugins when unreadable; bringing that in never removes a plugin,
so it is filed separately rather than changed here.
What was run:
- TestCollectStopsOnUnreadableSettings (new, internal/backup) and
TestSyncStopsOnUnreadableSettings (new, internal/davsync: two
computers on a fake WebDAV, a's file cut short with no .bak; a's sync
errs with no PUT, the status says so, the server keeps a's settings,
b keeps its own). Both FAIL on the old backup.go ("Collect read a
settings.json that can't be read as settings: <nil> &{Theme:system
..." and "a synced a broken settings.json") and PASS on the new, on
macOS and on the Windows box (cross-compiled binaries, sandbox home).
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
clean.
- go test -p 4 -timeout 40m ./... on macOS (origin/main 69d7ee33a plus
these three commits, load average 15-27 from other suites): every
package ok but internal/gateway, where TestMaxRPMTooLongIs429With
RetryAfter got 200 (the window had passed under load; #1791, open,
gateway untouched here). -run TestMaxRPM -count=3 passes on this
tree.
- After rebasing on origin/main 226222118 (which touched
internal/library): go vet darwin, GOOS=linux -tags nogui and
GOOS=windows clean; go test ./internal/update ./internal/pluginrt
./internal/backup ./internal/davsync ./internal/library
./internal/settings ok (library under -timeout 40m, 550 s at load
average ~60).
Not tried: a settings.json held open by another Windows program, or a
real WebDAV/S3/GitHub server.
The sealed setup is committed on every sync, so a public repository would
hand anyone every version of it, the whole history, to try passphrases on
offline. prepare now reads the repository's "private" field and refuses
before writing when it is false or missing, naming the repository and what
to do. The form's hint, the CLI usage and docs/reference.md say the
repository must be private; sync-backup.md lists the rule and its
verification command now points at ./internal/cli.
Run: go test -tags nogui ./internal/davsync/ and the cli tests
(TestGitHubCmd|TestWebdavCmd|TestS3Cmd|Help) green;
TestGitHubPublicRepositoryRefused goes red with the check removed. GUI:
github-sync, s3-sync, webdav-settings-refresh, sync-other-kind,
sync-not-backup, i18n-keys, gui-zh-tw, gui-ja, gui-de in Chromium and
WebKit, 72/72. Not tried against the real GitHub API.
A third sync kind: github://owner/repo[/folder] keeps the same sealed
backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a
repository the user already has, written through GitHub's Contents API
with a fine-grained token of its own (Contents read and write), kept in
sync.json apart from the library's GitHub token. The token goes only to
api.github.com: a redirect anywhere else is refused, and the passphrase
may not equal it. Each update is a commit; an empty repository is
initialised by the first backup. Settings › Sync gets a GitHub kind with
Repository, Branch, Folder and token; magpie github mirrors magpie s3.
Inactive servers of every kind are kept in Config.Servers (Other stays
for older clients).
Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d
onto main. Merge resolutions: the CLI moved to internal/cli since the PR
was cut, so github_cli_test.go moved there (package cli) and the github
command, its help line and `magpie help github` were wired in
internal/cli/main.go and help_cli.go; README's Sync row kept main's
links and took the PR's wording; i18n.js zh-TW kept both sides.