# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1638282257 -3600
# Node ID 395dce95508d51dce1f64aae8db7e93746b2de42
# Parent  6e1af07921d1574046d0ffec4640e5b43ccb7cfd
mod_storage_sql: Fix traceback on multi-user deletion

jid.join(true, ...) fails.

Since we don't know which users this affects, best to clear the whole
cache.

diff -r 6e1af07921d1 -r 395dce95508d plugins/mod_storage_sql.lua
--- a/plugins/mod_storage_sql.lua	Tue Nov 30 01:22:14 2021 +0100
+++ b/plugins/mod_storage_sql.lua	Tue Nov 30 15:24:17 2021 +0100
@@ -624,8 +624,12 @@
 		end
 		return engine:delete(sql_query, unpack(args));
 	end);
-	local cache_key = jid_join(username, host, self.store);
-	archive_item_count_cache:set(cache_key, nil);
+	if username == true then
+		archive_item_count_cache:clear();
+	else
+		local cache_key = jid_join(username, host, self.store);
+		archive_item_count_cache:set(cache_key, nil);
+	end
 	return ok and stmt:affected(), stmt;
 end