Skip to content
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

deleteStoredDeviceData does not wait for files to be deleted #498

Open
3 of 10 tasks
korzonkiee opened this issue Nov 5, 2024 · 6 comments
Open
3 of 10 tasks

deleteStoredDeviceData does not wait for files to be deleted #498

korzonkiee opened this issue Nov 5, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@korzonkiee
Copy link
Contributor

korzonkiee commented Nov 5, 2024

Platform on which you observed the bug:

  • Android
  • iOS
  • Other
  • Platform is not relevant for this bug

Device on which you observed the bug:

  • Polar OH1
  • Polar Verity Sense
  • Polar H10
  • Polar H9
  • Other
  • Device is not relevant for this bug

Describe the bug
Looking at the implementation of deleteDataDirectories on Android it looks like the method does not wait for all the underlying operations to complete. Also, in case of any errors they won't be reported, because the metod always returns complete.

Expected behavior
deleteDataDirectories method should complete after all files have been deleted, all errors should be reported to the caller that subscribes to it.

@korzonkiee korzonkiee added the bug Something isn't working label Nov 5, 2024
@korzonkiee korzonkiee changed the title On Android deleteStoredDeviceData does not wait for files to be deleted deleteStoredDeviceData does not wait for files to be deleted Nov 7, 2024
@korzonkiee
Copy link
Contributor Author

@korzonkiee
Copy link
Contributor Author

We managed to tweak the deleteListedFilesByType for AUTO_SAMPLE data type in our own fork. It now waits for deleting process to complete. Additionally it has been improved to respect the until date and log more for better visibility. Feel free to check it out, it may be helpful for someone responsible for implementing it into official repo.

korzonkiee@7bfb151

@korzonkiee
Copy link
Contributor Author

Implemented the same thing for Android.

korzonkiee@6dc58cf

@palmqvisti
Copy link
Contributor

Thank you for helping to solve this. The fix will be released in the next release.

@samulimaa
Copy link
Contributor

This should be fixed in the latest SDK release 5.10.0.

@korzonkiee
Copy link
Contributor Author

Thank you, @samulimaa. I appreciate you taking the time to investigate this.

If I understand correctly, the current implementation blocks the thread until deleteOpCompleted becomes true (see here). This flag is only set to true once all requested files have been deleted.

While this approach may work in the ideal case, I have concerns about its behavior when errors occur. For example, if a file deletion fails due to a connection interruption, deleteOpCompleted would never be set to true, causing the while loop to run indefinitely.

Given that the SDK relies heavily on the reactive paradigm through RxSwift and RxKotlin, I believe it would be beneficial to offer a solution that aligns with this pattern. While it may require more effort, such a solution would maintain consistency with the architecture and handle error cases more effectively. I am happy to assist with this, as I have already worked on similar improvements.

cc @palmqvisti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants