unterordner scanner
This commit is contained in:
@@ -57,8 +57,16 @@ function scriptFor(root) {
|
||||
function available() { return true }
|
||||
const cleanupAvailable = () => !!scriptFor(roots[0])
|
||||
|
||||
function psArgs(root, extra) {
|
||||
return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', root, ...extra, '-Json']
|
||||
// effRoot: the folder cleanup.ps1 treats as its root - for a project in a subfolder
|
||||
// ("Sammel\A") its parent folder, because the script only knows direct children
|
||||
function psArgs(root, extra, effRoot = root) {
|
||||
return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', effRoot, ...extra, '-Json']
|
||||
}
|
||||
// { effRoot, project, prefix } for cleanup.ps1; prefix turns its paths into "<folder>\..."
|
||||
function scriptTarget(root, folder) {
|
||||
const parent = path.dirname(folder)
|
||||
if (parent === '.' || !parent) return { effRoot: root, project: folder, prefix: '' }
|
||||
return { effRoot: path.join(root, parent), project: path.basename(folder), prefix: parent + path.sep }
|
||||
}
|
||||
|
||||
function parseJson(stdout) {
|
||||
@@ -125,11 +133,12 @@ async function sizeTree(dir) {
|
||||
|
||||
async function scanProject(root, folder) {
|
||||
const dir = path.join(root, folder)
|
||||
const st = scriptTarget(root, folder)
|
||||
const [split, cand] = await Promise.all([
|
||||
sizeTree(dir),
|
||||
scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS]), { timeout: 10 * 60 * 1000 }) : null,
|
||||
scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS], st.effRoot), { timeout: 10 * 60 * 1000 }) : null,
|
||||
])
|
||||
const candidates = cand ? parseJson(cand.stdout) : []
|
||||
const candidates = (cand ? parseJson(cand.stdout) : []).map((c) => (st.prefix && typeof c.Path === 'string' ? { ...c, Path: st.prefix + c.Path } : c))
|
||||
const deletable = { Cache: 0, Release: 0, Output: 0 }
|
||||
for (const c of candidates) if (!c.Skip) deletable[c.Tier] += c.MB
|
||||
const d = (all[rootKey(root)] ??= {})
|
||||
@@ -159,7 +168,9 @@ async function clean(root, folder, paths) {
|
||||
const only = paths.filter((p) => typeof p === 'string' && p.startsWith(prefix) && !p.includes('|'))
|
||||
if (!only.length) throw new Error('nichts ausgewählt')
|
||||
if (!scriptFor(root)) throw new Error('cleanup.ps1 nicht gefunden')
|
||||
const r = await run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS, '-Only', only.join('|'), '-Apply']), { timeout: 30 * 60 * 1000 })
|
||||
const st = scriptTarget(root, folder)
|
||||
const rel = only.map((p) => p.slice(st.prefix.length))
|
||||
const r = await run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS, '-Only', rel.join('|'), '-Apply'], st.effRoot), { timeout: 30 * 60 * 1000 })
|
||||
const result = parseJson(r.stdout)
|
||||
await scanProject(root, folder)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user