-
Haa you noticed... well, the
write
function is called by various Bangle events likeGPS
,HRM
andstep
. These are asynchronous, I didn't want them to try to write to the file while I am trying to clear the log. It may loose a few readings, that's fine for now.The code does clear logs successfully without corrupting the file system, but now I have hit the next issue. If the file reaches max-size and fails to write, the file system gets corrupt yet again. Going to attempt a few strategies to mitigate :-). First up compression to enable more data :-)
@PiOfThings, did you test the solution?
Because 'it' - the lock, the clear, the unlock - is in the same "js event thread". I'm not really clear about what has changed to make it work, since while the
.clearlog()
is executed and nothing in it is asynchronous / deferred, nothing else is executed (no parallel processing / threads). Setting the.currentFile
property controls the correct flow....