aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-26 00:20:24 +0100
committerKim Alvefur <zash@zash.se>2021-02-26 00:20:24 +0100
commitdfaf43cc3f4219d14c633a0e047d65dcc965b862 (patch)
treec6a9855350a5c1660c3e52dffa335b3d46b77c53
parenta2648b9d649df6caa39b36317cc9508545b78d98 (diff)
downloadprosody-dfaf43cc3f4219d14c633a0e047d65dcc965b862.tar.gz
prosody-dfaf43cc3f4219d14c633a0e047d65dcc965b862.zip
mod_http_file_share: Skip removal of nothing
In case none of the expired files could be deleted then it's a waste of an API call to try to remove any of the metadata at all.
-rw-r--r--plugins/mod_http_file_share.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index c66d7233..94b84867 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -423,12 +423,16 @@ if expiry >= 0 and not external_base_url then
deletion_query = {ids = obsolete_uploads};
end
- local removed, err = uploads:delete(nil, deletion_query);
-
- if removed == true or removed == n or removed == #obsolete_uploads then
- module:log("debug", "Removed all metadata for expired uploaded files");
+ if #obsolete_uploads == 0 then
+ module:log("debug", "No metadata to remove");
else
- module:log("error", "Problem removing metadata for deleted files: %s", err);
+ local removed, err = uploads:delete(nil, deletion_query);
+
+ if removed == true or removed == n 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);
+ end
end
prune_done();