Skip to content

Commit

Permalink
fix: invalid json array string for android file storage (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
bohan-amplitude authored Jul 28, 2022
1 parent 837895a commit 593050a
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ class EventsFileManager(
* stores the event
*/
suspend fun storeEvent(event: String) = mutex.withLock {
var newFile = false
var file = currentFile()
if (!file.exists()) {
// create it
file.createNewFile()
start(file)
newFile = true
}

// check if file is at capacity
Expand All @@ -51,12 +48,12 @@ class EventsFileManager(
// update index
file = currentFile()
file.createNewFile()
start(file)
newFile = true
}

var contents = ""
if (!newFile) {
if (file.length() == 0L) {
start(file)
} else if (file.length() > 1) {
contents += ","
}
contents += event
Expand Down

0 comments on commit 593050a

Please sign in to comment.