aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-11-30 00:53:22 +0100
committerKim Alvefur <zash@zash.se>2021-11-30 00:53:22 +0100
commitd2f4a57bfc2c51958a63ac2475376cc3e5ba3e4f (patch)
tree7dab453f7c63ddcb39616dfeec2946ad6d8cefed /plugins
parent4836354fd0d6c1194bb0e02248edce16e253914e (diff)
downloadprosody-d2f4a57bfc2c51958a63ac2475376cc3e5ba3e4f.tar.gz
prosody-d2f4a57bfc2c51958a63ac2475376cc3e5ba3e4f.zip
mod_http_file_share: Merge file expiry loops
Not sure what the benefit of two separate loops was, perhaps reduced memory usage by allowing archive query state to be garbage collected before moving on to deleting files. Never measured so probably not so. This simplifies a bit.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http_file_share.lua20
1 files changed, 7 insertions, 13 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index 3daca396..bec56cd5 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -477,29 +477,23 @@ if expiry >= 0 and not external_base_url then
local obsolete_uploads = array();
local i = 0;
local size_sum = 0;
+ local n = 0;
+ local problem_deleting = false;
for slot_id, slot_info in iter do
i = i + 1;
- obsolete_uploads:push(slot_id);
upload_cache:set(slot_id, nil);
- size_sum = size_sum + tonumber(slot_info.attr.size);
- end
-
- sleep(0.1);
- local n = 0;
- local problem_deleting = false;
- obsolete_uploads:filter(function(slot_id)
- n = n + 1;
- if i % 100 == 0 then sleep(0.1); end
local filename = get_filename(slot_id);
local deleted, err, errno = os.remove(filename);
if deleted or errno == ENOENT then
- return true;
+ size_sum = size_sum + tonumber(slot_info.attr.size);
+ obsolete_uploads:push(slot_id);
else
module:log("error", "Could not delete file %q: %s", filename, err);
problem_deleting = true;
- return false;
end
- end);
+ if i % 100 == 0 then sleep(0.1); end
+ end
+
-- obsolete_uploads now contains slot ids for which the files have been
-- deleted and that needs to be cleared from the database