Skip to content

Commit

Permalink
fix(server/inventory): pcall when saving inventories
Browse files Browse the repository at this point in the history
Possibly fix some cases of an error thrown causing isSaving
to never reset to false? Never repro'd, but still best to fix.
  • Loading branch information
thelindat committed Mar 1, 2024
1 parent cadcd53 commit f1b4118
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,6 @@ local inventoryClearTime = GetConvarInt('inventory:cleartime', 5) * 60
local function saveInventories(clearInventories)
if isSaving then return end

isSaving = true
local time = os.time()
local parameters = { {}, {}, {}, {} }
local total = { 0, 0, 0, 0, 0 }
Expand All @@ -2295,10 +2294,12 @@ local function saveInventories(clearInventories)
end

if total[5] > 0 then
db.saveInventories(parameters[1], parameters[2], parameters[3], parameters[4], total)
end
isSaving = true
local ok, err = pcall(db.saveInventories, parameters[1], parameters[2], parameters[3], parameters[4], total)
isSaving = false

isSaving = false
if not ok and err then return lib.print.error(err) end
end

if not clearInventories then return end

Expand Down

0 comments on commit f1b4118

Please sign in to comment.