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

Fix hive persistence issue #363

Closed

Conversation

yashas-hm
Copy link
Contributor

PR Description

Added a directory path for hive to store files. The path is application support directory which will be accessible by the app irrespective of permissions by the OS firewall.

By default hive stores its files at getApplicationDocumentsDirectory

Use getApplicationSupportDirectory instead of getApplicationDocumentsDirectory to ensure read and write permissions.
https://github.com/hivedb/hive/blob/3b12c31a221f97f5ec86fe20df63515aeedf88f0/hive_flutter/lib/src/hive_extensions.dart#L16

Related issue
isar/hive#1044

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

  • No, and this is why: Not Required

@animator
Copy link
Member

animator commented Mar 28, 2024

In the documentation, it is written -

Your app should not use this directory for user data files.

Apart from some configs, we are majorly storing user data so documents folder is the right location.

@yashas-hm
Copy link
Contributor Author

My approach to solve the solution was this as support folder is always accessible. The other option is to store in app cache directory else we can prompt the use that access to the particular folder is not possible please give API Dash permission to read and write to the folder.

The document folder would not be accessible only if the user has denied permissions or added an additional firewall which would not the case for most of the users.

@yashas-hm
Copy link
Contributor Author

yashas-hm commented Mar 28, 2024

Apart from some configs, we are majorly storing user data so documents folder is the right location.

I think the documentation mentions the user data such as user details like name, phone etc. user sensitive details.

I guess using getLibraryDirectory would be more logical.

Documentation Reference:

Path to the directory where application can store files that are persistent,
backed up, and not visible to the user, such as sqlite.db.

@animator
Copy link
Member

animator commented Mar 28, 2024

Nope. Closing this PR as this is not a path issue, but permission and error handling issue.

@animator animator closed this Mar 28, 2024
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.

Saving state never terminates if persistent files cannot be accessed / modified
2 participants