Software / code / prosody
Comparison
plugins/mod_storage_internal.lua @ 13344:958c759d3897
mod_storage_internal: Close lazy-loading list abstraction after trim
Should be done here too.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Nov 2023 14:35:26 +0100 |
| parent | 13343:9a9455de295d |
| child | 13346:53c347043cb5 |
comparison
equal
deleted
inserted
replaced
| 13343:9a9455de295d | 13344:958c759d3897 |
|---|---|
| 358 end | 358 end |
| 359 | 359 |
| 360 -- shortcut: check if the last item should be trimmed, if so, drop the whole archive | 360 -- shortcut: check if the last item should be trimmed, if so, drop the whole archive |
| 361 local last = list[#list].when or datetime.parse(list[#list].attr.stamp); | 361 local last = list[#list].when or datetime.parse(list[#list].attr.stamp); |
| 362 if last <= to_when then | 362 if last <= to_when then |
| 363 if list.close then | |
| 364 list:close() | |
| 365 end | |
| 363 return datamanager.list_store(username, host, self.store, nil); | 366 return datamanager.list_store(username, host, self.store, nil); |
| 364 end | 367 end |
| 365 | 368 |
| 366 -- luacheck: ignore 211/exact | 369 -- luacheck: ignore 211/exact |
| 367 local i, exact = binary_search(list, function(item) | 370 local i, exact = binary_search(list, function(item) |
| 368 local when = item.when or datetime.parse(item.attr.stamp); | 371 local when = item.when or datetime.parse(item.attr.stamp); |
| 369 return to_when - when; | 372 return to_when - when; |
| 370 end); | 373 end); |
| 374 if list.close then | |
| 375 list:close() | |
| 376 end | |
| 371 -- TODO if exact then ... off by one? | 377 -- TODO if exact then ... off by one? |
| 372 if i == 1 then return 0; end | 378 if i == 1 then return 0; end |
| 373 local ok, err = datamanager.list_shift(username, host, self.store, i); | 379 local ok, err = datamanager.list_shift(username, host, self.store, i); |
| 374 if not ok then return ok, err; end | 380 if not ok then return ok, err; end |
| 375 return i-1; | 381 return i-1; |