Hello,
I’ve got a very tricky problem in my app. It happens only very occasionally, only to a very small amount of users. However, when it happens, they lose all their game progress. So I really would like to solve this issue.
I’m using GGData (Source code) for saving/reading data. Generally everything works fine. However, in some rare cases, the files in which the data is stored, are empty. They exist, but they are completely empty.
This can’t happen on a “normal” way, since the writing is done the following way, and json.encode will never return an empty string:
data = json.encode( data ) path = system.pathForFile( self.path .. "/" .. self.id .. ".box", system.DocumentsDirectory ) local file = io.open( path, "w" ) if not file then return end file:write( data )
I also built in a debug event to check whether data is nil before writing, which does not happen.
What I did find out so far is, that with opening the file in “w” mode, it becomes empty. So if the writing would fail afterwards, the file would stay empty (is there any alternative to that? Some kind of “safe” opening mode?)
I’m using 3 “GGData-box” objects parallel, so 3 files are involved as well. Could it be a problem when trying to write to 2 different files (that means using GGData:save()) at the same time?
The problem occurs both on iOS and Android.
Has anyone experienced something similar or has ideas or other input on this issue?
Best regards!