diff --git a/assets/javascripts/admintable.js b/assets/javascripts/admintable.js index 03de98da..fa6a477e 100644 --- a/assets/javascripts/admintable.js +++ b/assets/javascripts/admintable.js @@ -265,6 +265,24 @@ function renderAdminReadonly(data, type, row, meta) { return data ? data : ''; } +function renderAdminSize(data, type, row, meta) { + if(type === 'display' && data) { + if (Math.abs(data) < 1024) { + return data; + } + const units = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + let u = -1; + + do { + data /= 1024; + ++u; + } while (Math.round(Math.abs(data) * 10) >= 1024 && u < units.length - 1); + + return data.toFixed(1) + ' ' + units[u]; + } + return data ? data : ''; +} + function renderAdminTableSettingsList(data, type, row, meta) { var plainText = type !== 'display'; var edit = isEditingAdminTableRow(meta); @@ -442,7 +460,7 @@ function setupAdminTable(editable) { } emptyRow[columnName] = ""; } else if (th.hasClass('col_ro')) { - columnDef.render = renderAdminReadonly; + columnDef.render = (columnName == 'size'? renderAdminSize : renderAdminReadonly); emptyRow.settings = {}; } else if (th.hasClass('col_unixtime')) { columnDef.render = renderAdminUnixtime; diff --git a/lib/MirrorCache/Task/ReportProjectSize.pm b/lib/MirrorCache/Task/ReportProjectSize.pm index 74fe0257..abd3bb00 100644 --- a/lib/MirrorCache/Task/ReportProjectSize.pm +++ b/lib/MirrorCache/Task/ReportProjectSize.pm @@ -30,9 +30,6 @@ sub _run { return $job->finish('Previous report job is still active for ' . $path) unless my $guard = $minion->guard('report_project_size_' . $path, 30*60); - my $realpath = $app->mc->root->rootpath($path); - return $job->fail('Path not found: ' . $path) unless $realpath; - my ($size, $file_cnt, $lm) = $app->schema->resultset('Folder')->calculate_disk_usage($path); $job->note("total size" => $size, "file count" => $file_cnt, "last modified" => $lm); diff --git a/lib/MirrorCache/WebAPI/Plugin/Backstage.pm b/lib/MirrorCache/WebAPI/Plugin/Backstage.pm index 96035fb2..d2548bd0 100644 --- a/lib/MirrorCache/WebAPI/Plugin/Backstage.pm +++ b/lib/MirrorCache/WebAPI/Plugin/Backstage.pm @@ -34,7 +34,7 @@ sub new { } my @permanent_jobs = - qw(folder_sync_schedule_from_misses folder_sync_schedule mirror_scan_schedule_from_misses mirror_scan_schedule_from_path_errors mirror_scan_schedule project_sync_schedule cleanup stat_agg_schedule mirror_check_from_stat report); + qw(folder_sync_schedule_from_misses folder_sync_schedule mirror_scan_schedule_from_misses mirror_scan_schedule_from_path_errors mirror_scan_schedule project_sync_schedule cleanup stat_agg_schedule mirror_check_from_stat report report_project_size_schedule); sub register_tasks { my $self = shift; @@ -46,10 +46,6 @@ sub register_tasks { if ($app->mcconfig->mirror_provider) { push @permanent_jobs, 'mirror_provider_sync'; } - eval { - my $projects = $app->mcproject->list; - push @permanent_jobs, 'report_project_size_schedule' if @$projects; - }; $app->plugin($_) for (