Skip to content

Commit 7f1a93a

Browse files
committed
loadFromFile now creates backup if serialization is successful and it has data
1 parent 522a3c0 commit 7f1a93a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

load/save.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ function loadFromFile(filename)
1414
if file_data == nil then
1515
return {} -- new object
1616
end
17-
else
18-
love.filesystem.write(filename..".backup", file_data) -- backup creation if sucessful
1917
end
2018
local result, save_data = pcall(binser.deserialize, file_data)
2119
if result == false or save_data == nil then
2220
return {} -- new object
21+
else
22+
love.filesystem.write(filename..".backup", file_data) -- backup creation if sucessful
2323
end
2424
return save_data[1]
2525
end

0 commit comments

Comments
 (0)