From 82f6358657d85762ece207a1ff9aba18150f22f3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 30 Nov 2021 00:55:54 +0100 Subject: mod_http_file_share: Keep global storage use accurate longer. Merging those loops removes the miscounting that would occur in case a file could not be deleted, so no need to limit it to that case. --- plugins/mod_http_file_share.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/mod_http_file_share.lua') diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index bec56cd5..4fc5a3b5 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -500,10 +500,6 @@ if expiry >= 0 and not external_base_url then local deletion_query = {["end"] = boundary_time}; if not problem_deleting then module:log("info", "All (%d, %s) expired files successfully deleted", n, B(size_sum)); - if total_storage_usage then - total_storage_usage = total_storage_usage - size_sum; - module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); - end -- we can delete based on time else module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n); @@ -511,10 +507,14 @@ if expiry >= 0 and not external_base_url then -- successfully deleted, and then try again with the failed ones. -- eventually the admin ought to notice and fix the permissions or -- whatever the problem is. - -- total_storage_limit will be inaccurate until this has been resolved deletion_query = {ids = obsolete_uploads}; end + if total_storage_usage then + total_storage_usage = total_storage_usage - size_sum; + module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); + end + if #obsolete_uploads == 0 then module:log("debug", "No metadata to remove"); else -- cgit v1.2.3