plugins/autofire: don't save 2bytes cfg file (#6960)

This commit is contained in:
kunikuni 2020-07-18 04:05:23 +09:00 committed by GitHub
parent 4f6f6e13c4
commit 33fbb85d59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,9 +76,14 @@ function lib:save_settings(buttons)
end
local json = require('json')
local settings = serialize_settings(buttons)
local data = json.stringify(settings, {indent = true})
if string.len(data) <= 2 then
os.remove(path .. get_settings_filename())
return
end
local file = io.open(path .. get_settings_filename(), 'w')
if file then
file:write(json.stringify(settings, {indent = true}))
file:write(data)
file:close()
end
end