fix: show all leftover sessions — resumable ones get Resume, stale ones get Clean Up

This commit is contained in:
Claus Lohmar 2026-07-27 07:52:48 +00:00
parent df6b8085ca
commit e53fcacaa6
2 changed files with 17 additions and 3 deletions

View file

@ -166,13 +166,12 @@ def list_sessions():
continue
archives = {".7z", ".zip", ".rar", ".tar.gz", ".tgz", ".tar", ".gz", ".bz2", ".xz", ".ova"}
has_source = has_disks or any(f["name"].lower().endswith(tuple(archives)) for f in session_files)
if not has_source:
continue
sessions.append({
"session_id": entry.name,
"files": session_files[:10],
"total_size_gb": round(total_bytes / (1024**3), 1),
"has_disks": has_disks,
"resumable": has_source,
})
except Exception:
pass

View file

@ -109,7 +109,11 @@ async function loadSessions() {
html += '<div><span class="pve-code">' + s.session_id.substring(0, 8) + '</span> &mdash; ' + fileNames + ' <span class="pve-dim">(' + s.total_size_gb + ' GiB)</span>';
if (s.has_disks) html += ' <span class="pve-badge pve-badge-completed" style="font-size:0.65rem;">extracted</span>';
html += '</div>';
html += '<button class="pve-btn pve-btn-primary pve-btn-small" onclick="resumeSession(\'' + s.session_id + '\', \'' + firstFile.replace(/'/g, "\\'") + '\')">Resume</button>';
if (s.resumable) {
html += '<button class="pve-btn pve-btn-primary pve-btn-small" onclick="resumeSession(\'' + s.session_id + '\', \'' + firstFile.replace(/'/g, "\\'") + '\')">Resume</button>';
} else {
html += '<button class="pve-btn pve-btn-small" onclick="cleanupSession(\'' + s.session_id + '\', this)">Clean Up</button>';
}
html += '</div>';
}
list.innerHTML = html;
@ -139,6 +143,17 @@ function resumeSession(sessionId, firstFile) {
document.getElementById('source-url').required = false;
}
function cleanupSession(sessionId, btn) {
if (!confirm('Delete session ' + sessionId.substring(0, 8) + '?')) return;
btn.disabled = true;
btn.textContent = '...';
fetch('/session/cleanup/cleanup_' + sessionId, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ delete_staging_files: true, session_id: sessionId })
}).then(function() { loadSessions(); });
}
function setPhase(label, pct, isSpinner) {
const el = document.getElementById('phase-label');
const fill = document.getElementById('pve-progress-bar');