Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/pages/fileBrowser/fileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
20 changes: 0 additions & 20 deletions src/plugins/terminal/scripts/init-sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions src/plugins/terminal/www/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const Terminal = {
readAsset("init-sandbox.sh"),
]);

await this.migrateLegacyHome();

const isFdroid = await Executor.execute("echo $FDROID");

if(isFdroid !== "true"){
Expand Down Expand Up @@ -567,6 +569,56 @@ 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<void>}
*/
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"
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"
if cp -a "$PREFIX/alpine/root/." "$MIGRATE/root/"; then
COPIED=true
else
exit 1
fi
fi
Comment thread
RohitKushvaha01 marked this conversation as resolved.

# 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
};

Expand Down
Loading