Skip to content

Fix to append rather than overwrite data in existing files #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

dannys42
Copy link
Contributor

The existing code will result in malformed JSON being sent to the server because of partial events overwriting the start of existing files. This fix will ensure we always append to a pre-existing file.

Comment on lines 56 to 60
if #available(iOS 13.4, *) {
_ = try? fileHandle?.seekToEnd()
} else {
try? fileHandle?.seek(toOffset: .max)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely could improve with code for all supported platforms

@bsneed
Copy link
Contributor

bsneed commented Jan 26, 2023

Thanks @dannys42 @dmcgloin! I haven't seen this happen before (not saying it's not possible, just that I haven't seen it) in my testing or test suites. It definitely can't hurt for sure though. Thanks so much for the PR!

@bsneed bsneed merged commit 0a55564 into segmentio:main Jan 26, 2023
@dmcgloin
Copy link

Thanks for merging, @bsneed. Any idea when a release is targeted with this change?

@bsneed
Copy link
Contributor

bsneed commented Feb 3, 2023

Just released. Thanks @dmcgloin ! https://github.com/segmentio/analytics-swift/releases/tag/1.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants