Skip to content

fix: terminal backup#1985

Draft
RohitKushvaha01 wants to merge 7 commits intoAcode-Foundation:mainfrom
RohitKushvaha01:main
Draft

fix: terminal backup#1985
RohitKushvaha01 wants to merge 7 commits intoAcode-Foundation:mainfrom
RohitKushvaha01:main

Conversation

@RohitKushvaha01
Copy link
Copy Markdown
Member

@RohitKushvaha01 RohitKushvaha01 commented Mar 27, 2026

Closes #1965

@RohitKushvaha01 RohitKushvaha01 marked this pull request as draft March 27, 2026 08:47
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR fixes a filename mismatch in the terminal backup/restore flow. The backup operation always created aterm_backup.tar, but the restore path was reading from aterm_backup.bin (in Terminal.js) and the settings UI was copying into and cleaning up a file named aterm_backup / aterm_backup.bin — meaning restore was completely broken. All three references are now aligned to aterm_backup.tar.

Additionally, the backup EXCLUDE list is extended with Android-specific bind-mount directories (apex, odm, product, system_ext, linkerconfig) and Linux virtual filesystems (proc, sys, dev, run, tmp), which prevents those transient/virtual paths from inflating or corrupting a PRoot backup archive.

Key changes:

  • Terminal.js restore(): aterm_backup.binaterm_backup.tar (core bug fix)
  • terminalSettings.js terminalRestore(): copy target and cleanup filename corrected to aterm_backup.tar
  • File picker MIME type broadened from application/x-tar to application/octet-stream
  • A stale inline comment (atem_backup.bin) was not updated alongside the code fix

Confidence Score: 5/5

Safe to merge — fixes a clear filename mismatch that made restore completely non-functional; remaining findings are minor style issues.

The core bug (.bin vs .tar mismatch) is correctly fixed across all three callsites. The additional EXCLUDE entries are conservative and correct. The only open items are a stale comment and a style note about the MIME type breadth — neither blocks functionality.

No files require special attention beyond the stale comment at src/settings/terminalSettings.js:331.

Important Files Changed

Filename Overview
src/plugins/terminal/www/Terminal.js Fixes restore command to extract from aterm_backup.tar (was .bin), extends EXCLUDE list with Android bind-mount dirs (apex, odm, proc, sys, dev, etc.) to prevent backup bloat. Cosmetic blank-line removal.
src/settings/terminalSettings.js Fixes copy-destination and cleanup filenames from aterm_backup / aterm_backup.bin to aterm_backup.tar. Changes file-picker MIME type from application/x-tar to application/octet-stream (wider filter). Stale comment still references old .bin name.

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])
Loading

Comments Outside Diff (1)

  1. src/settings/terminalSettings.js, line 331 (link)

    P2 Stale inline comment

    The comment still refers to the old filename atem_backup.bin, which was exactly the bug being fixed in this PR. It should be updated to reflect the correct .tar extension.

Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | Re-trigger Greptile

},
toast,
"application/x-tar",
"application/octet-stream",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

Can't backup Terminal.

1 participant