mod_http_file_share: Rename variable for clarity
authorKim Alvefur <zash@zash.se>
Sat, 04 Dec 2021 15:03:52 +0100
changeset 12010 62a466e60515
parent 12009 797197b8607e
child 12011 dc72581e04ff
mod_http_file_share: Rename variable for clarity
plugins/mod_http_file_share.lua
--- a/plugins/mod_http_file_share.lua	Sat Dec 04 14:28:04 2021 +0100
+++ b/plugins/mod_http_file_share.lua	Sat Dec 04 15:03:52 2021 +0100
@@ -478,11 +478,11 @@
 		end
 
 		local obsolete_uploads = array();
-		local n = 0;
+		local num_expired = 0;
 		local size_sum = 0;
 		local problem_deleting = false;
 		for slot_id, slot_info in iter do
-			n = n + 1;
+			num_expired = num_expired + 1;
 			upload_cache:set(slot_id, nil);
 			local filename = get_filename(slot_id);
 			local deleted, err, errno = os.remove(filename);
@@ -493,7 +493,7 @@
 				module:log("error", "Could not delete file %q: %s", filename, err);
 				problem_deleting = true;
 			end
-			if n % 100 == 0 then sleep(0.1); end
+			if num_expired % 100 == 0 then sleep(0.1); end
 		end
 
 		-- obsolete_uploads now contains slot ids for which the files have been
@@ -501,10 +501,10 @@
 
 		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));
+			module:log("info", "All (%d, %s) expired files successfully deleted", num_expired, B(size_sum));
 			-- we can delete based on time
 		else
-			module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n);
+			module:log("warn", "%d out of %d expired files could not be deleted", num_expired-#obsolete_uploads, num_expired);
 			-- we'll need to delete only those entries where the files were
 			-- successfully deleted, and then try again with the failed ones.
 			-- eventually the admin ought to notice and fix the permissions or
@@ -523,7 +523,7 @@
 		else
 			local removed, err = uploads:delete(nil, deletion_query);
 
-			if removed == true or removed == n or removed == #obsolete_uploads then
+			if removed == true or removed == num_expired or removed == #obsolete_uploads then
 				module:log("debug", "Removed all metadata for expired uploaded files");
 			else
 				module:log("error", "Problem removing metadata for deleted files: %s", err);