fix: terminal backup#1985
Conversation
Greptile SummaryThis PR fixes a filename mismatch in the terminal backup/restore flow. The backup operation always created Additionally, the backup Key changes:
Confidence Score: 5/5Safe to merge — fixes a clear filename mismatch that made restore completely non-functional; remaining findings are minor style issues. The core bug ( No files require special attention beyond the stale comment at Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([User: Backup]) --> B[FileBrowser: pick folder]
B --> C[Terminal.backup]
C --> D{Alpine installed?}
D -- No --> E[reject: Alpine not installed]
D -- Yes --> F["tar -cf $PREFIX/aterm_backup.tar\n(with EXCLUDE dirs)"]
F --> G{result == 'ok'?}
G -- No --> H[reject with output]
G -- Yes --> I[copyToUri → user folder as aterm_backup.tar]
I --> J([Backup complete])
K([User: Restore]) --> L["sdcard.openDocumentFile\n(MIME: application/octet-stream)"]
L --> M["copyToUri → cordova.file.dataDirectory/aterm_backup.tar"]
M --> N[Terminal.restore]
N --> O[Stop AXS if running]
O --> P[Delete existing alpine/axs/…]
P --> Q["tar -xf $PREFIX/aterm_backup.tar -C $PREFIX"]
Q --> R{result == 'ok'?}
R -- No --> S[reject with output]
R -- Yes --> T[delete temp aterm_backup.tar]
T --> U([Restore complete])
|
src/settings/terminalSettings.js
Outdated
| }, | ||
| toast, | ||
| "application/x-tar", | ||
| "application/octet-stream", |
There was a problem hiding this comment.
MIME type change widens file picker filter
Changing from "application/x-tar" to "application/octet-stream" makes the file picker show all files instead of only .tar archives. While this is a pragmatic choice given Android's inconsistent MIME type associations for .tar files, it means a user can accidentally select any binary file and attempt a restore with it. Terminal.restore() will only fail after copying the wrong file to $PREFIX and running tar -xf on it.
If application/x-tar did not work reliably on device (which is a valid reason), consider also trying "application/x-tar,application/octet-stream" as a comma-separated fallback list (if the sdcard.openDocumentFile API supports it), or at least add a filename validation step before the restore to check that the selected file ends with .tar.
Closes #1965