From c467e354a4b409f6f411c7caa9d57f1742c46778 Mon Sep 17 00:00:00 2001 From: Rohit Kushwaha Date: Fri, 14 Aug 2026 17:57:29 +0530 Subject: [PATCH 1/2] fix: migration --- src/pages/fileBrowser/fileBrowser.js | 7 +++ src/plugins/terminal/scripts/init-sandbox.sh | 20 --------- src/plugins/terminal/www/Terminal.js | 46 ++++++++++++++++++++ 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/pages/fileBrowser/fileBrowser.js b/src/pages/fileBrowser/fileBrowser.js index e977eb59d9..dbde83462f 100644 --- a/src/pages/fileBrowser/fileBrowser.js +++ b/src/pages/fileBrowser/fileBrowser.js @@ -1332,6 +1332,13 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { uuid: "terminal-public", }); } + + // Migrate any files left in the legacy alpine/home and + // alpine/root directories into public/MIGRATE so they are + // not hidden after the home/root/public merge. + if (typeof Terminal !== "undefined" && Terminal.migrateLegacyHome) { + Terminal.migrateLegacyHome(); + } } catch (err) { console.error("Error while adding public directory", err); } diff --git a/src/plugins/terminal/scripts/init-sandbox.sh b/src/plugins/terminal/scripts/init-sandbox.sh index b16096f12b..5e100ef9e4 100644 --- a/src/plugins/terminal/scripts/init-sandbox.sh +++ b/src/plugins/terminal/scripts/init-sandbox.sh @@ -4,26 +4,6 @@ mkdir -p "$PREFIX/tmp" mkdir -p "$PREFIX/alpine/tmp" mkdir -p "$PREFIX/public" -SRC1="$PREFIX/alpine/home" -SRC2="$PREFIX/alpine/root" -DEST="$PREFIX/public" - -mkdir -p "$DEST" - -move_all() { - SRC="$1" - - [ -d "$SRC" ] || return 0 - - # Only continue if directory is not empty - [ "$(find "$SRC" -mindepth 1 -maxdepth 1 | head -n 1)" ] || return 0 - - find "$SRC" -mindepth 1 -maxdepth 1 -exec mv -f {} "$DEST"/ \; -} - -move_all "$SRC1" -move_all "$SRC2" - export PROOT_TMP_DIR=$PREFIX/tmp if [ "$FDROID" = "true" ]; then diff --git a/src/plugins/terminal/www/Terminal.js b/src/plugins/terminal/www/Terminal.js index e6332b32fe..9bfb9fcd2f 100644 --- a/src/plugins/terminal/www/Terminal.js +++ b/src/plugins/terminal/www/Terminal.js @@ -21,6 +21,8 @@ const Terminal = { readAsset("init-sandbox.sh"), ]); + await this.migrateLegacyHome(); + const isFdroid = await Executor.execute("echo $FDROID"); if(isFdroid !== "true"){ @@ -567,6 +569,50 @@ const Terminal = { }); }, + /** + * Migrates the legacy terminal home directories into public/MIGRATE. + * Older builds stored user files under alpine/home and alpine/root. + * After /home, /root and /public were merged into a single public + * directory, any files still left in the old locations are copied + * into public/MIGRATE (keeping their source structure) so nothing is + * hidden or lost. This is a no-op once the migration has run. + * @returns {Promise} + */ + async migrateLegacyHome() { + if (this._legacyHomeMigrated) return; + try { + const cmd = ` + MIGRATE="$PREFIX/public/MIGRATE" + + # Already migrated + [ -e "$MIGRATE/.migrated" ] && exit 0 + + COPIED=false + + if [ -d "$PREFIX/alpine/home" ] && [ -n "$(find "$PREFIX/alpine/home" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then + mkdir -p "$MIGRATE/home" + cp -a "$PREFIX/alpine/home/." "$MIGRATE/home/" + COPIED=true + fi + + if [ -d "$PREFIX/alpine/root" ] && [ -n "$(find "$PREFIX/alpine/root" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then + mkdir -p "$MIGRATE/root" + cp -a "$PREFIX/alpine/root/." "$MIGRATE/root/" + COPIED=true + fi + + # Mark as migrated so this only runs once + if [ "$COPIED" = "true" ]; then + touch "$MIGRATE/.migrated" + fi + `; + await Executor.BackgroundExecutor.execute(cmd); + this._legacyHomeMigrated = true; + } catch (error) { + console.error("Failed to migrate legacy terminal home:", formatError(error)); + } + }, + formatError }; From 24d7c0e91a6a537ff7153371c65a632c6c8c0ea6 Mon Sep 17 00:00:00 2001 From: Rohit Kushvaha Date: Fri, 14 Aug 2026 18:02:07 +0530 Subject: [PATCH 2/2] Update src/plugins/terminal/www/Terminal.js Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/plugins/terminal/www/Terminal.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/terminal/www/Terminal.js b/src/plugins/terminal/www/Terminal.js index 9bfb9fcd2f..21ffde3755 100644 --- a/src/plugins/terminal/www/Terminal.js +++ b/src/plugins/terminal/www/Terminal.js @@ -591,14 +591,20 @@ const Terminal = { if [ -d "$PREFIX/alpine/home" ] && [ -n "$(find "$PREFIX/alpine/home" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then mkdir -p "$MIGRATE/home" - cp -a "$PREFIX/alpine/home/." "$MIGRATE/home/" - COPIED=true + if cp -a "$PREFIX/alpine/home/." "$MIGRATE/home/"; then + COPIED=true + else + exit 1 + fi fi if [ -d "$PREFIX/alpine/root" ] && [ -n "$(find "$PREFIX/alpine/root" -mindepth 1 -maxdepth 1 2>/dev/null | head -n 1)" ]; then mkdir -p "$MIGRATE/root" - cp -a "$PREFIX/alpine/root/." "$MIGRATE/root/" - COPIED=true + if cp -a "$PREFIX/alpine/root/." "$MIGRATE/root/"; then + COPIED=true + else + exit 1 + fi fi # Mark as migrated so this only runs once