Software /
code /
prosody
Changeset
11406:9d6545a7d483
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 26 Feb 2021 00:20:24 +0100 |
parents | 11405:ce8291e89d67 |
children | 11408:1b6298e7b550 |
files | plugins/mod_http_file_share.lua |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua Thu Feb 25 23:58:08 2021 +0100 +++ b/plugins/mod_http_file_share.lua Fri Feb 26 00:20:24 2021 +0100 @@ -423,12 +423,16 @@ deletion_query = {ids = obsolete_uploads}; end - local removed, err = uploads:delete(nil, deletion_query); + if #obsolete_uploads == 0 then + module:log("debug", "No metadata to remove"); + else + 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); + 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();