Fix APK v3 Xray extraction on OpenWrt 25

This commit is contained in:
kzolotarev95 committed 2026-10-29 13:32:42 +04:00
1 parent d7d350fd8b
commit fcde23bfc4
5 files changed
+376 -9

No files matched your search

+17 -8
View File
@@ -1837,7 +1837,9 @@ xray_package_extract_binary() (
trap cleanup_package_extract EXIT trap cleanup_package_extract EXIT
trap 'exit 1' INT TERM trap 'exit 1' INT TERM
mkdir -p "$work/data" || return 1 mkdir -p "$work/data" || return 1
case "$archive" in # The bounded downloader stages every format as xray.pkg. Select the
# extractor from the release asset, not the temporary file's extension.
case "${3:-$archive}" in
*.ipk|*.pkg) *.ipk|*.pkg)
# yichya's .ipk release is a gzip-compressed tar containing # yichya's .ipk release is a gzip-compressed tar containing
# data.tar.gz. Support both this format and classic ar-wrapped ipk. # data.tar.gz. Support both this format and classic ar-wrapped ipk.
@@ -1858,12 +1860,19 @@ xray_package_extract_binary() (
# /usr/bin/xray before our transport check has accepted the package. # /usr/bin/xray before our transport check has accepted the package.
;; ;;
*.apk) *.apk)
# apk packages are handled by apk itself on Alpine-based images. # OpenWrt 25 uses APK v3/ADB, not a gzip tarball. Extract offline
if command -v apk >/dev/null 2>&1; then # into RAM; never install into /usr/bin or change the package DB.
apk add --allow-untrusted "$archive" >/dev/null 2>&1 || return 1 command -v apk >/dev/null 2>&1 || { log 'Xray: для извлечения APK требуется apk extract'; return 1; }
[ -x /usr/bin/xray ] || return 1 if apk extract --allow-untrusted --no-chown --destination "$work/data" "$archive" >"$work/extract.log" 2>&1; then
cp /usr/bin/xray "$output" if [ -s "$work/data/usr/bin/xray" ] && [ ! -L "$work/data/usr/bin/xray" ]; then
return $? mv "$work/data/usr/bin/xray" "$output" || return 1
return 0
fi
log 'Xray: APK извлечён, но в пакете нет обычного файла usr/bin/xray'
else
rc=$?
log "Xray: ошибка apk extract (rc=$rc); системный Xray и база пакетов не изменены"
head -c 4096 "$work/extract.log" >&2
fi fi
;; ;;
esac esac
@@ -1901,7 +1910,7 @@ install_xray_tmp_locked() (
return 1 return 1
} }
mv -f "$package.new" "$package" || return 1 mv -f "$package.new" "$package" || return 1
xray_package_extract_binary "$package" "$dir/xray.new" || { xray_package_extract_binary "$package" "$dir/xray.new" "$asset" || {
log "Xray: не удалось извлечь /usr/bin/xray из пакета $asset; рабочий бинарник сохранён" log "Xray: не удалось извлечь /usr/bin/xray из пакета $asset; рабочий бинарник сохранён"
return 1 return 1
} }
+44
View File
@@ -117,3 +117,47 @@ JSON не заменяются. Проверяется SHA-256 реально з
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-reverse-vps.ps1" -Vps "root@138.124.79.58" -Action Install powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-reverse-vps.ps1" -Vps "root@138.124.79.58" -Action Install
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-reverse-vps.ps1" -Vps "root@138.124.79.58" -Action Rollback powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-reverse-vps.ps1" -Vps "root@138.124.79.58" -Action Rollback
``` ```
## Установка APK на OpenWrt 25
Пакет `openwrt-xray-26.6.27-r1-aarch64_generic.apk` имеет формат APK v3/ADB
(`ADBd` в начале файла). Загрузчик сохраняет любой пакет как `xray.pkg`;
прежний распаковщик выбирал IPK по этому временному имени. Даже при прямом
вызове ветка APK использовала `apk add` и могла установить файлы в системный
`/usr/bin`, не проверив новый бинарник заранее.
Теперь исходное имя release asset передаётся распаковщику отдельным аргументом.
Для APK выполняется `apk extract --allow-untrusted --no-chown --destination`
в отдельный каталог RAM. Команда не устанавливает зависимости и не меняет
базу пакетов. После извлечения проверяется обычный файл `usr/bin/xray`;
проверки размера, запуска и совместимости транспорта остаются обязательными.
Ошибки `apk extract` показывают код и ограниченный фрагмент настоящего вывода.
Неполный кандидат и временный каталог удаляются; старый бинарник, UCI и кэш
не заменяются при неудаче.
В OpenWrt 25.12 используется apk-tools 3.0.5 с `minimal=true`; команда
`extract` входит и в минимальную сборку. Источники:
- https://github.com/openwrt/openwrt/blob/openwrt-25.12/package/system/apk/Makefile
- https://github.com/alpinelinux/apk-tools/blob/v3.0.5/meson.build
- https://github.com/alpinelinux/apk-tools/blob/v3.0.5/src/app_extract.c
Локальная установка заменяет только агент и повторяет `prepare-xray`.
Если первая установка прервалась до создания `/etc/owrt-remote/web.key`,
после подготовки Xray создаётся случайный ключ входа. Имеющийся ключ сохраняется.
Это завершает необходимый для открытия панели шаг прерванного `install.sh`:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-apk-fix.ps1" -Router "root@192.168.2.1" -Action Install
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-xray-apk-fix.ps1" -Router "root@192.168.2.1" -Action Rollback
```
Резервная копия агента: `/root/owrt-remote-backup-before-xray-apk-v119`.
Откат возвращает агент, сохраняя подготовленный бинарник и boot-кэш.
Рабочий JSON не пересобирается, туннель не перезапускается.
Тесты проверяют полный bootstrap с форматом APK и временным именем `.pkg`,
неудачное извлечение, отсутствие бинарника, несовместимого кандидата и IPK.
В тестах shell работает настоящий BusyBox ash, вызов `apk` заменён тестовым
обработчиком. Настоящий APK скачан и его формат проверен; запуск нативного
`apk extract` на OpenWrt 25.12.5 требуется подтвердить установкой на устройстве.
+70
View File
@@ -0,0 +1,70 @@
"""Local APK bootstrap update preserves code on failure and keeps the CGI untouched."""
import unittest
import test_xray_validation_deploy as base
class XrayApkDeploymentTests(base.XrayValidationDeploymentTests):
deploy_name = 'deploy-xray-apk-fix.ps1'
backup_name = 'owrt-remote-backup-before-xray-apk-v119'
success_marker = 'XRAY_APK_ROUTER_Install_OK'
def setUp(self):
super().setUp()
self.cgi_path = self.targets.pop('cgi')
self.old_cgi = self.original.pop('cgi')
self.key_file = self.root / 'web.key'
self.script = self.script.replace('key_file=/etc/owrt-remote/web.key',
'key_file=' + self.key_file.as_posix())
self.script = self.script.replace('/usr/sbin/owrt-remote prepare-xray', 'test_prepare_xray')
self.script = '''test_prepare_xray() { return "${PREPARE_RC:-0}"; }
''' + self.script
def deploy(self, *args, **kwargs):
result = super().deploy(*args, **kwargs)
self.assertEqual(self.cgi_path.read_bytes(), self.old_cgi)
return result
def test_bad_candidate_and_missing_backup_leave_both_files_unchanged(self):
result = self.deploy('Install', bad_item='agent')
self.assertNotEqual(result.returncode, 0)
self.assertFalse(self.backup.exists())
self.assertEqual(self.targets['agent'].read_bytes(), self.original['agent'])
result = self.deploy('Rollback')
self.assertNotEqual(result.returncode, 0)
self.assertIn('No complete backup', result.stderr)
self.assertEqual(self.targets['agent'].read_bytes(), self.original['agent'])
def test_failed_xray_preparation_restores_agent_and_retains_backup(self):
self.env['PREPARE_RC'] = '13'
result = self.deploy('Install')
self.assertEqual(result.returncode, 13, result.stderr)
self.assertNotIn(self.success_marker, result.stdout)
self.assertIn('prepare-xray-apk', result.stderr)
self.assertEqual(self.targets['agent'].read_bytes(), self.original['agent'])
self.assertEqual(self.backup.joinpath('agent').read_bytes(), self.original['agent'])
self.assertFalse(self.key_file.exists())
def test_verify_failure_restores_both_files(self):
result = self.deploy('Install', fail_verify=True)
self.assertNotEqual(result.returncode, 0)
self.assertIn('Restoring the previous agent', result.stderr)
self.assertEqual(self.targets['agent'].read_bytes(), self.original['agent'])
self.assertFalse(self.key_file.exists())
def test_interrupted_first_install_gets_a_key_without_replacing_existing_key(self):
result = self.deploy('Install')
self.assertEqual(result.returncode, 0, result.stderr)
key = self.key_file.read_bytes()
self.assertEqual(len(key), 32)
self.assertTrue(all(chr(c) in '0123456789abcdef' for c in key))
self.assertNotIn(key.decode(), result.stdout + result.stderr)
custom = b'keep-the-existing-key\n'
self.key_file.write_bytes(custom)
result = self.deploy('Install')
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(self.key_file.read_bytes(), custom)
if __name__ == '__main__':
unittest.main()
+95 -1
View File
@@ -48,6 +48,10 @@ ulimit() { [ "$1 $2" = '-f 32768' ]; }
xray_process_identity() { XRAY_SELF_PID=$$; XRAY_SELF_BIRTH=1; } xray_process_identity() { XRAY_SELF_PID=$$; XRAY_SELF_BIRTH=1; }
xray_process_start() { [ "$1" != "$$" ] || printf 1; } xray_process_start() { [ "$1" != "$$" ] || printf 1; }
''' '''
self.raw_process_mocks = r'''
xray_process_identity() { XRAY_SELF_PID=$$; XRAY_SELF_BIRTH=1; }
xray_process_start() { [ "$1" != "$$" ] || printf 1; }
''' if os.environ.get('OWRT_TEST_BUSYBOX') and os.name == 'nt' else ''
def shell(self, commands, mocks='', **env): def shell(self, commands, mocks='', **env):
shell = os.environ.get('OWRT_TEST_BUSYBOX', base.SH) shell = os.environ.get('OWRT_TEST_BUSYBOX', base.SH)
@@ -62,7 +66,7 @@ xray_process_start() { [ "$1" != "$$" ] || printf 1; }
shell = os.environ.get('OWRT_TEST_BUSYBOX', base.SH) shell = os.environ.get('OWRT_TEST_BUSYBOX', base.SH)
args = [shell, 'ash'] if 'busybox' in shell.lower() else [shell] args = [shell, 'ash'] if 'busybox' in shell.lower() else [shell]
script = self.directory / 'raw-run.sh' script = self.directory / 'raw-run.sh'
script.write_text(self.agent + '\n' + base.MOCKS + '\n' + mocks + '\n' + commands, script.write_text(self.agent + '\n' + base.MOCKS + '\n' + self.raw_process_mocks + '\n' + mocks + '\n' + commands,
encoding='utf-8', newline='\n') encoding='utf-8', newline='\n')
return subprocess.run(args + [script.as_posix()], capture_output=True, encoding='utf-8', return subprocess.run(args + [script.as_posix()], capture_output=True, encoding='utf-8',
env={**self.env, **env}, timeout=40) env={**self.env, **env}, timeout=40)
@@ -103,6 +107,95 @@ opkg() {
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual((self.directory / 'extracted').read_bytes(), binary) self.assertEqual((self.directory / 'extracted').read_bytes(), binary)
APK_EXTRACT_MOCK = r'''
apk() {
local destination archive allow
[ "$1" != --print-arch ] || { echo aarch64_generic; return 0; }
printf '%s\n' "$*" >>"$TEST_ROOT/apk-calls"
# Package installation/dependency resolution must never be used here.
[ "$1" = extract ] || return 91
shift
destination=''; archive=''; allow=0
while [ "$#" -gt 0 ]; do
case "$1" in
--allow-untrusted) allow=1; shift ;;
--no-chown) shift ;;
--destination) destination="$2"; shift 2 ;;
*) archive="$1"; shift ;;
esac
done
[ -n "$destination" ] && [ "$allow" = 1 ] && [ -s "$archive" ] || return 92
case "$destination" in "$TEST_ROOT/"*.package-extract.*/data) ;; *) return 93 ;; esac
mkdir -p "$destination/usr/bin"
if [ "${TEST_APK_FAIL:-0}" != 0 ]; then
echo 'ERROR: package integrity check failed' >&2
echo partial >"$destination/usr/bin/xray"
return "$TEST_APK_FAIL"
fi
[ "${TEST_APK_EMPTY:-0}" = 0 ] || return 0
cp "$TEST_ROOT/package-binary" "$destination/usr/bin/xray"
}
ensure_ca_certificates() { return 0; }
ensure_fetch_tool() { return 0; }
xray_cache_dir() { printf '%s' "$TEST_ROOT/flash"; }
fetch_file() { echo "$1" >>"$TEST_ROOT/downloads"; cp "$TEST_ROOT/release.pkg" "$2"; }
'''
def apk_fixture(self, binary=None):
# Same ADBd signature as the downloaded yichya APK v3, staged under the
# format-neutral xray.pkg name used by the actual bootstrap.
(self.directory / 'release.pkg').write_bytes(b'ADBd-test-package')
data = binary or self.make_binary('Xray 26.6.27 APK')
(self.directory / 'package-binary').write_bytes(data)
return data
def test_apk_bootstrap_selects_real_format_despite_pkg_staging_name(self):
data = self.apk_fixture()
result = self.raw_shell('install_xray_tmp', mocks=self.APK_EXTRACT_MOCK)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn('OK: Xray installed', result.stdout)
self.assertEqual(self.binary.read_bytes(), data)
self.assertIn('/openwrt-xray-26.6.27-r1-aarch64_generic.apk',
(self.directory / 'downloads').read_text())
self.assertTrue((self.directory / 'apk-calls').read_text().startswith('extract '))
self.assertTrue(list(self.store.glob('openwrt-xray-26.6.27-r1-aarch64_generic.apk.*.gz')))
self.assert_clean()
def test_apk_extract_failure_reports_real_reason_and_preserves_working_state(self):
good = self.apk_fixture()
cached = self.cache(good)
original_uci = (self.directory / 'uci').read_bytes()
result = self.raw_shell('install_xray_tmp', mocks=self.APK_EXTRACT_MOCK, TEST_APK_FAIL='13')
self.assertNotEqual(result.returncode, 0)
self.assertIn('apk extract (rc=13)', result.stderr)
self.assertIn('package integrity check failed', result.stderr)
self.assertNotIn('OK: Xray installed', result.stdout)
self.assertEqual(self.binary.read_bytes(), good)
self.assertEqual((self.directory / 'uci').read_bytes(), original_uci)
self.assertTrue(cached.exists())
self.assert_clean()
def test_apk_without_binary_fails_without_touching_working_core(self):
good = self.apk_fixture()
result = self.raw_shell('install_xray_tmp', mocks=self.APK_EXTRACT_MOCK, TEST_APK_EMPTY='1')
self.assertNotEqual(result.returncode, 0)
self.assertIn('usr/bin/xray', result.stderr)
self.assertNotIn('OK: Xray installed', result.stdout)
self.assertEqual(self.binary.read_bytes(), good)
self.assert_clean()
def test_apk_candidate_transport_is_validated_before_replacing_core(self):
bad = self.incompatible_binary()
good = self.make_binary('Xray 26.6.27 working')
self.apk_fixture(bad)
original_uci = (self.directory / 'uci').read_bytes()
result = self.raw_shell('install_xray_tmp', mocks=self.APK_EXTRACT_MOCK)
self.assertEqual(result.returncode, 23, result.stderr)
self.assertIn('vless without TLS', result.stderr)
self.assertEqual(self.binary.read_bytes(), good)
self.assertEqual((self.directory / 'uci').read_bytes(), original_uci)
self.assert_clean()
def cache(self, data=None): def cache(self, data=None):
data = data or self.make_binary() data = data or self.make_binary()
self.store.mkdir(exist_ok=True) self.store.mkdir(exist_ok=True)
@@ -116,6 +209,7 @@ opkg() {
self.assertFalse(list(self.runtime.glob('.restore.*'))) self.assertFalse(list(self.runtime.glob('.restore.*')))
self.assertFalse(list(self.runtime.glob('.compat.*'))) self.assertFalse(list(self.runtime.glob('.compat.*')))
self.assertFalse((self.runtime / 'xray.pkg').exists()) self.assertFalse((self.runtime / 'xray.pkg').exists())
self.assertFalse(list(self.runtime.glob('*.package-extract.*')))
def test_compatible_mipsel_ipk_and_apk_asset_names(self): def test_compatible_mipsel_ipk_and_apk_asset_names(self):
for fmt, expected in ( for fmt, expected in (
+150
View File
@@ -0,0 +1,150 @@
param(
[ValidateNotNullOrEmpty()][string]$Router = 'root@192.168.2.1',
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
[switch]$PrepareOnly
)
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-xray-apk-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
$Payloads = @{
'agent' = 'files\usr\sbin\owrt-remote'
}
$RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup_dir=/root/owrt-remote-backup-before-xray-apk-v119
key_file=/etc/owrt-remote/web.key
key_candidate=$key_file.new-__UPLOAD_NAME__
changed=0
phase=preflight
item_path() {
case "$1" in
agent) printf /usr/sbin/owrt-remote ;;
esac
}
complete_backup() {
[ -f "$1/complete" ] && [ -s "$1/agent" ]
}
restore_files() {
local dir item path
dir=$1
complete_backup "$dir" || return 1
for item in agent; do
path=$(item_path "$item")
cp -p "$dir/$item" "$path.new-__UPLOAD_NAME__" || return 1
mv -f "$path.new-__UPLOAD_NAME__" "$path" || return 1
done
}
cleanup() {
code=$?
trap - EXIT
if [ "$code" -ne 0 ]; then
printf 'Failed during %s (rc=%s).\n' "$phase" "$code" >&2
if [ "$changed" = 1 ]; then
echo 'Restoring the previous agent from this attempt.' >&2
restore_files "$stage/previous" || echo 'Restore failed; retained backup is available.' >&2
fi
fi
for item in agent; do path=$(item_path "$item"); rm -f "$path.new-__UPLOAD_NAME__"; done
rm -f "$key_candidate"
rm -rf "$stage"
exit "$code"
}
trap cleanup EXIT
trap 'exit 1' INT TERM
for item in agent; do
path=$(item_path "$item")
test -s "$path"
done
if [ '__ACTION__' = Install ]; then
for item in agent; do test -s "$stage/$item"; sh -n "$stage/$item"; done
grep -F -q 'xray_validate_transport_binary()' "$stage/agent"
grep -F -q '26.6.27' "$stage/agent"
grep -F -q 'apk extract --allow-untrusted --no-chown --destination' "$stage/agent"
grep -F -q 'xray_package_extract_binary "$package" "$dir/xray.new" "$asset"' "$stage/agent"
if [ ! -e "$backup_dir" ]; then
mkdir -p "$stage/retained-backup"
chmod 700 "$stage/retained-backup"
for item in agent; do path=$(item_path "$item"); cp -p "$path" "$stage/retained-backup/$item"; done
touch "$stage/retained-backup/complete"
mv "$stage/retained-backup" "$backup_dir"
fi
complete_backup "$backup_dir" || { echo "Incomplete backup: $backup_dir. Nothing changed." >&2; exit 1; }
source_dir=$stage
else
complete_backup "$backup_dir" || { echo "No complete backup: $backup_dir. Nothing changed." >&2; exit 1; }
for item in agent; do sh -n "$backup_dir/$item"; done
source_dir=$backup_dir
fi
printf 'Backup: %s\n' "$backup_dir"
mkdir -p "$stage/previous"
for item in agent; do path=$(item_path "$item"); cp -p "$path" "$stage/previous/$item"; done
touch "$stage/previous/complete"
phase=install
changed=1
for item in agent; do
path=$(item_path "$item")
cp "$source_dir/$item" "$path.new-__UPLOAD_NAME__"
chmod 755 "$path.new-__UPLOAD_NAME__"
mv -f "$path.new-__UPLOAD_NAME__" "$path"
done
phase=verify
for item in agent; do
path=$(item_path "$item")
sh -n "$path"
cmp "$source_dir/$item" "$path"
done
if [ '__ACTION__' = Install ]; then
phase=prepare-xray-apk
# Replaces a known incompatible core, or restores/downloads a validated
# compatible one. Does not render JSON or restart an existing tunnel.
/usr/sbin/owrt-remote prepare-xray
# install.sh creates the web key after Xray preparation. Recover that last
# step if the first installation was interrupted by the APK defect.
if [ ! -s "$key_file" ]; then
phase=finish-first-install
mkdir -p "$(dirname "$key_file")"
if command -v hexdump >/dev/null 2>&1; then
(umask 077; dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -v -e '16/1 "%02x"' >"$key_candidate")
else
(umask 077; dd if=/dev/urandom bs=16 count=1 2>/dev/null | od -An -v -tx1 | tr -d ' \n' >"$key_candidate")
fi
[ "$(wc -c <"$key_candidate")" -eq 32 ] || { echo 'Web key generation failed.' >&2; exit 1; }
chmod 600 "$key_candidate"
mv -f "$key_candidate" "$key_file"
echo 'Web key created for the interrupted first installation.'
fi
fi
# Rollback restores agent code only; retain the validated compatible core,
# its boot cache, and all router settings. Never remove a working executable.
printf '\nXRAY_APK_ROUTER_%s_OK\n' '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'run.sh'), $RemoteScript.Replace("`r`n", "`n") + "`n", $Utf8)
if ($Action -eq 'Install') {
foreach ($Item in $Payloads.GetEnumerator()) {
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot $Item.Value)).Replace("`r`n", "`n")
[System.IO.File]::WriteAllText((Join-Path $StageRoot $Item.Key), $Content, $Utf8)
}
}
if ($PrepareOnly) { Write-Host "Prepared only: $StageRoot"; return }
& scp -O -r -- $StageRoot "${Router}:/tmp/"
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. The installation has not started.' }
& ssh -T -o ConnectTimeout=10 $Router "sh /tmp/$UploadName/run.sh"
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
Write-Host "Xray APK fix $Action finished successfully."
} finally {
if (-not $PrepareOnly) {
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) { throw 'Unsafe staging cleanup path.' }
if (Test-Path -LiteralPath $Resolved) { Remove-Item -LiteralPath $Resolved -Recurse -Force }
}
}