foss42 / apidash

API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. A lightweight alternative to postman/insomnia.
https://apidash.dev
Apache License 2.0
1.43k stars 269 forks source link

Fix hive persistence issue #363

Closed yashas-hm closed 5 months ago

yashas-hm commented 5 months ago

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 https://github.com/isar/hive/issues/1044

Related Issues

Checklist

Added/updated tests?

animator commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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