Software /
code /
prosody
File
util/adhoc.lua @ 13262:9a86e7cbdd79
mod_storage_internal: Fix fast trimming of archive with exactly one item
This method would previously never delete the first (and only) item
since it works out which item should become the first item after the
trim operation, which doesn't make sense when all should be removed.
This also works as an optimization for when all the last item should be
trimmed, thus items should be removed.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Sep 2023 13:41:54 +0200 |
parent | 11352:e10567199f02 |
line wrap: on
line source
-- luacheck: ignore 212/self local function new_simple_form(form, result_handler) return function(self, data, state) if state or data.form then if data.action == "cancel" then return { status = "canceled" }; end local fields, err = form:data(data.form); return result_handler(fields, err, data); else return { status = "executing", actions = {"next", "complete", default = "complete"}, form = form }, "executing"; end end end local function new_initial_data_form(form, initial_data, result_handler) return function(self, data, state) if state or data.form then if data.action == "cancel" then return { status = "canceled" }; end local fields, err = form:data(data.form); return result_handler(fields, err, data); else local values, err = initial_data(data); if type(err) == "table" then return {status = "error"; error = err} elseif type(err) == "string" then return {status = "error"; error = {type = "cancel"; condition = "internal-server-error", err}} end return { status = "executing", actions = {"next", "complete", default = "complete"}, form = { layout = form, values = values } }, "executing"; end end end return { new_simple_form = new_simple_form, new_initial_data_form = new_initial_data_form };