Diff

plugins/mod_http_file_share.lua @ 11994:f9b2325f6b50

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.
author Kim Alvefur <zash@zash.se>
date Tue, 30 Nov 2021 00:55:54 +0100
parent 11993:aa60f4353001
child 11998:99be6874340b
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua	Tue Nov 30 00:53:22 2021 +0100
+++ b/plugins/mod_http_file_share.lua	Tue Nov 30 00:55:54 2021 +0100
@@ -500,10 +500,6 @@
 		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 @@
 			-- 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