mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
fix(ugc): purging and the storage cap delete folders off the main thread
Purge all ran on the UGC server's main thread inside the dashboard's request: it measured and deleted every stored folder, then updated rows one by one, and the main thread (downloads, the master link, the database) waited minutes for it. Now a purge answers at once and a file thread lists, measures and deletes the folders; the main thread applies what it removed and updates the rows a few hundred a tick. No new item is started while a purge runs, and items being made when it starts are left alone, so no worker writes into a folder being deleted. One purge at a time. The storage cap's clean-up lists and deletes on the same thread. The UGC page shows the purge's progress (/status purge). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -314,6 +314,7 @@
|
||||
meter('Jobs\' memory', s.jobMemoryBytes || 0, l.maxMemoryBytes || 0, esc(mb(s.jobMemoryBytes || 0)) + ' estimated' +
|
||||
(l.maxMemoryBytes ? ' of ' + esc(mb(l.maxMemoryBytes)) : ', no limit') + (s.memoryWaits ? ', ' + esc(s.memoryWaits) + ' waits' : '')) +
|
||||
'</div>' + (l.nice ? '<div class="text-body-secondary">Workers run at priority ' + esc(l.nice) + '.</div>' : '') +
|
||||
purgeLine(s.purge) +
|
||||
(last ? '<div class="text-body-secondary">Last: ' + esc(last.kind) + ' ' + esc(last.id) + (last.ok ? ' made in ' + esc(duration(last.ms)) : ' failed') +
|
||||
(last.message ? ' (' + esc(last.message) + ')' : '') + '</div>' : '');
|
||||
}).catch(function () { box.innerHTML = fmt.badge('Unknown', 'secondary') + ' Couldn\'t ask the dashboard for the UGC server\'s status.'; });
|
||||
@@ -597,9 +598,19 @@
|
||||
|
||||
// ---- deleting and purging stored files ----
|
||||
|
||||
// The running or last purge (the UGC server deletes folders in the background)
|
||||
function purgeLine(p) {
|
||||
if (!p || !p.state) return '';
|
||||
var what = (p.kind === 'modular' ? 'cars and rockets' : 'models');
|
||||
var counts = esc(p.deleted) + ' deleted (' + esc(mb(p.bytes || 0)) + '), ' + esc(p.checked) + (p.total ? ' of ' + esc(p.total) : '') + ' looked at';
|
||||
if (p.state === 'done') return '<div class="text-body-secondary">Last purge (' + what + '): ' + counts + ', finished ' + esc(new Date(p.finished * 1000).toLocaleString()) + '.</div>';
|
||||
return '<div>' + fmt.badge(p.state === 'saving' ? 'Purge: updating the rows' : 'Purging', 'info') + ' ' + what + ': ' + counts + '. New items wait until it is done.</div>';
|
||||
}
|
||||
|
||||
function showDeleteResult(box, d) {
|
||||
if (!d.success) { toast(d.error || 'Failed', 'danger'); return; }
|
||||
var text = d.deleted + ' deleted (' + mb(d.bytes || 0) + ' freed). ' + (d.notes || []).join(' ');
|
||||
var text = d.started ? 'Deleting ' + (d.queued ? d.queued + ' item(s)' : 'every stored item') + ' in the background. ' + (d.notes || []).join(' ')
|
||||
: (d.notes && d.notes.length && !d.deleted ? d.notes.join(' ') : d.deleted + ' deleted (' + mb(d.bytes || 0) + ' freed). ' + (d.notes || []).join(' '));
|
||||
if (box) box.textContent = text;
|
||||
toast(text, 'success');
|
||||
load();
|
||||
|
||||
Reference in New Issue
Block a user