fix: show all leftover sessions — resumable ones get Resume, stale ones get Clean Up
This commit is contained in:
parent
df6b8085ca
commit
e53fcacaa6
2 changed files with 17 additions and 3 deletions
|
|
@ -166,13 +166,12 @@ def list_sessions():
|
||||||
continue
|
continue
|
||||||
archives = {".7z", ".zip", ".rar", ".tar.gz", ".tgz", ".tar", ".gz", ".bz2", ".xz", ".ova"}
|
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)
|
has_source = has_disks or any(f["name"].lower().endswith(tuple(archives)) for f in session_files)
|
||||||
if not has_source:
|
|
||||||
continue
|
|
||||||
sessions.append({
|
sessions.append({
|
||||||
"session_id": entry.name,
|
"session_id": entry.name,
|
||||||
"files": session_files[:10],
|
"files": session_files[:10],
|
||||||
"total_size_gb": round(total_bytes / (1024**3), 1),
|
"total_size_gb": round(total_bytes / (1024**3), 1),
|
||||||
"has_disks": has_disks,
|
"has_disks": has_disks,
|
||||||
|
"resumable": has_source,
|
||||||
})
|
})
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,11 @@ async function loadSessions() {
|
||||||
html += '<div><span class="pve-code">' + s.session_id.substring(0, 8) + '</span> — ' + fileNames + ' <span class="pve-dim">(' + s.total_size_gb + ' GiB)</span>';
|
html += '<div><span class="pve-code">' + s.session_id.substring(0, 8) + '</span> — ' + 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>';
|
if (s.has_disks) html += ' <span class="pve-badge pve-badge-completed" style="font-size:0.65rem;">extracted</span>';
|
||||||
html += '</div>';
|
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>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
list.innerHTML = html;
|
list.innerHTML = html;
|
||||||
|
|
@ -139,6 +143,17 @@ function resumeSession(sessionId, firstFile) {
|
||||||
document.getElementById('source-url').required = false;
|
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) {
|
function setPhase(label, pct, isSpinner) {
|
||||||
const el = document.getElementById('phase-label');
|
const el = document.getElementById('phase-label');
|
||||||
const fill = document.getElementById('pve-progress-bar');
|
const fill = document.getElementById('pve-progress-bar');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue