Preserve known top-level upgrade directories

This commit is contained in:
FengLee
2026-05-10 09:21:42 +08:00
parent ded16b8778
commit adef2da1d9

View File

@@ -49,6 +49,11 @@ const COLD_ALLOWED_FILES = new Set([
const BLOCKED_TOP_LEVEL_NAMES = new Set(['.git', 'node_modules', '.next', 'dist', 'backups', 'local-storage', 'upgrade-state']);
const BLOCKED_ANYWHERE_NAMES = new Set(['.git', 'node_modules', '.next']);
const PAYLOAD_TOP_LEVEL_DIRECTORIES = new Set([
...HOT_ALLOWED_PREFIXES.map(prefix => prefix.replace(/\/$/, '')),
...COLD_ALLOWED_PREFIXES.map(prefix => prefix.replace(/\/$/, '')),
...BLOCKED_TOP_LEVEL_NAMES,
]);
let state = readState() || {
id: jobId,
@@ -382,7 +387,7 @@ function isAllowedArchive(file) {
function resolvePayloadRoot(root) {
const entries = fs.readdirSync(root, { withFileTypes: true }).filter(entry => entry.name !== '__MACOSX');
if (entries.length === 1 && entries[0].isDirectory()) {
if (entries.length === 1 && entries[0].isDirectory() && !PAYLOAD_TOP_LEVEL_DIRECTORIES.has(entries[0].name)) {
return path.join(root, entries[0].name);
}
return root;