Comparison

plugins/mod_http_file_share.lua @ 11784:f0971a9eba88

mod_http_file_share: Fix traceback in global quota debug logging (thanks Martin) Error in util.human.units.format because of B(nil) when the global quota is unset.
author Kim Alvefur <zash@zash.se>
date Sun, 12 Sep 2021 11:47:22 +0200
parent 11781:9c23e7c8a67a
child 11794:5d925f340ae6
comparison
equal deleted inserted replaced
11783:7bf246e6792b 11784:f0971a9eba88
450 prune_done(); 450 prune_done();
451 return; 451 return;
452 end 452 end
453 453
454 module:log("info", "Pruning expired files uploaded earlier than %s", dt.datetime(boundary_time)); 454 module:log("info", "Pruning expired files uploaded earlier than %s", dt.datetime(boundary_time));
455 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); 455 if total_storage_limit then
456 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit));
457 end
456 458
457 local obsolete_uploads = array(); 459 local obsolete_uploads = array();
458 local i = 0; 460 local i = 0;
459 local size_sum = 0; 461 local size_sum = 0;
460 for slot_id, slot_info in iter do 462 for slot_id, slot_info in iter do
486 local deletion_query = {["end"] = boundary_time}; 488 local deletion_query = {["end"] = boundary_time};
487 if not problem_deleting then 489 if not problem_deleting then
488 module:log("info", "All (%d, %s) expired files successfully deleted", n, B(size_sum)); 490 module:log("info", "All (%d, %s) expired files successfully deleted", n, B(size_sum));
489 if total_storage_usage then 491 if total_storage_usage then
490 total_storage_usage = total_storage_usage - size_sum; 492 total_storage_usage = total_storage_usage - size_sum;
491 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); 493 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit));
492 end 494 end
493 -- we can delete based on time 495 -- we can delete based on time
494 else 496 else
495 module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n); 497 module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n);
496 -- we'll need to delete only those entries where the files were 498 -- we'll need to delete only those entries where the files were