Software / code / prosody
Comparison
plugins/mod_storage_internal.lua @ 8142:13e075549cb3
mod_storage_internal: Correctly calculate number of deleted items (fixes #912)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 14 May 2017 17:22:33 +0200 |
| parent | 8089:4ba8cb75d925 |
| child | 8143:c4c159953c72 |
comparison
equal
deleted
inserted
replaced
| 8141:03714861f8fc | 8142:13e075549cb3 |
|---|---|
| 139 if k ~= "end" then return nil, "unsupported-query-field"; end | 139 if k ~= "end" then return nil, "unsupported-query-field"; end |
| 140 end | 140 end |
| 141 local items, err = datamanager.list_load(username, host, self.store); | 141 local items, err = datamanager.list_load(username, host, self.store); |
| 142 if not items then return items, err; end | 142 if not items then return items, err; end |
| 143 items = array(items); | 143 items = array(items); |
| 144 local count_before = #items; | |
| 144 items:filter(function (item) | 145 items:filter(function (item) |
| 145 return item.when > query["end"]; | 146 return item.when > query["end"]; |
| 146 end); | 147 end); |
| 147 local count = #items; | 148 local count = count_before - #items; |
| 148 local ok, err = datamanager.list_store(username, host, self.store, items); | 149 local ok, err = datamanager.list_store(username, host, self.store, items); |
| 149 if not ok then return ok, err; end | 150 if not ok then return ok, err; end |
| 150 return count; | 151 return count; |
| 151 end | 152 end |
| 152 | 153 |