Repository navigation
Fix import/export bugs and keep the UI responsive - #121
Merged
Merged
Conversation
Import no longer wipes preferences that aren't in the backup, and no longer reports a failure after the data has been replaced. Backups with missing sections read as empty, cancelling the save dialog is silent, read-only files can be imported, and the export file name always uses the Gregorian date.
Reading a backup now drops points that have no day or category, finds the data file by name in any folder or casing, and reports damaged or foreign files with a readable message. Built-in categories are added back right after an import. Backups record a format and app version, carry the theme, device colors and hide notes settings, and skip unset preferences and the unused mood_palette. Export and import run off the UI thread so the spinner shows straight away. The backup snapshot loads each table once, the bulk add skips change detection, the JSON is compact and the archive is no longer copied before saving. The copy Android makes of a picked file is deleted after the import.
The picker reports the copy under /data/data while FileSystem.CacheDirectory is /data/user/0, so the prefix check never matched on a device.
Only a hand-edited backup has points without a day or category, and the change detection tweak made no difference to import time on the Android emulator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #118. Works through the import/export audit there. Old app versions can still import files written by this one: a new backup imports into a build of main on the Android 17 emulator.
These are the bugs the audit reproduced:
FileSaverResult.IsSuccessfulis justException is null, so the old cancelled branch could never run. On Android, main shows "Export failed: TaskCanceledException_ctor_DefaultMessage".File.OpenRead, so read-only files and files open in another program can be imported.backup-2026-11-21on a Thai, Arabic or Persian device too.Reading a backup is also more forgiving and says more when it fails:
BackupReadExceptionwith a message for the user ("This file isn't a Journal App backup, or it's damaged.", "This backup is damaged and can't be read.") and the original exception goes to the log. That includes the CRC32 check .NET 11 added to zip reads, which has a test that flips one byte in a stored entry. File system errors show "The file couldn't be opened." and a failed database replace says the current data was not changed.FormatVersionandAppVersion. A backup with a higher format version than the app knows gets a warning in the confirmation. Files without them read as before.What goes into a backup changed a little:
theme,device_colorsandhide_notesare exported when the user has set them, and restored through their typed setters so the stored types stay right.mood_paletteis no longer written. One consequence: importing a backup that has no safety plan now leaves the device's current safety plan alone instead of clearing it.And the UI no longer freezes while it works:
Task.Run, so the spinner paints. In the Windows Release build with 2348 days and 17010 points the spinner entered the DOM 19 ms after clicking Export (1253 ms before), and 6 ms after confirming an import, with no frame gap over 9 ms during the 2.7 s replace.CreateBackuploads each table once and lets the change tracker fix up the collections. Same build and data: 554 ms, down from 1066 ms.On the Android 17 emulator (Release, CoreCLR, about 17000 points, single runs, so treat as rough) the steps cost about the same as on main: read around 360 ms, replace around 3.1 s, create backup 730 to 790 ms. The archive went from 991 KB to 905 KB. So on Android the gain is that the UI isn't frozen for those seconds, not that they got shorter.
The real apps were run too: on Windows, an export through the Save dialog and an import of that file through the Open dialog, and on the emulator export, import, cancel, a file that isn't a backup, and Back pressed twice during an import. In both, theme and "hide notes" (and device colors on Android) were changed after the export and came back from the import. Not run on a physical phone.
Not done from #118: dropping points that have no day or category (only a hand-edited backup has them), the bulk add change (no difference on the emulator), saving the import in chunks, password protected backups and opening
.journalappfiles from Windows.