-
Notifications
You must be signed in to change notification settings - Fork 408
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
Use support dir instead of document dir #746
base: main
Are you sure you want to change the base?
Conversation
First of all thanks for your effort to contribute into Hive project 😊 This change is fine, unless the developer automatically updates packages and tries to read Hive file from document directory manually, since hive is widely used, there might be some use cases that this change will going to break. Also hive does supports initializing in custom directories (by calling Maybe we could keep old |
Using a separate function could be a good idea, it could also include something like I won't be able to work on this for a few days but I'll probably make another function for the support dir when I can :) |
Another note: I didn't realise that iOS hides the documents path by default, I had UISupportsDocumentBrowser enabled. This PR is still relevant for desktop/iOS apps that use the documents library. |
Just pushed a new commit to make the documents dir the default. If developers want to migrate to the support dir, they should set |
I am going to advocate for a breaking change, and use I ended up here after wondering why I had Hive files appearing in my home directory (because I disabled the xdg 'Documents' directory). Even without that though, I consider I can manually initialize with an appropriate directory now that I know what is going on, but that doesn't help every new developer who tries to use Hive. |
|
It defaults to ~/Documents, until it is fixed we specify ~/.local/share/<app> isar/hive#746
I am not certain about other platforms, but at least for Linux the current Hive implementation goes against specs:
|
Currently, Hive uses
getApplicationDocumentsDir
as a base directory to store files. On Android, this is fine since the documents dir is hidden from the user, but on iOS and Desktop, the documents dir is in a user-readable location. On iOS, it returns a folder in the user's "On My iPhone" section, and on Desktop it just returns the user's home or documents directory. This could confuse the user and may cause them to lose data by deleting the files. On iOS, the documents directory is also backed up to iCloud by default, which could annoy the user.I have changed
initFlutter
to usegetApplicationSupportDir
instead. This returns a hidden location on all platforms. To handle DBs in old locations, the old location is looped through and all .hive/ files (and the accompanying .lock files) are copied to the new location. The vast majority of apps using Hive shouldn't have to do anything to migrate to this version, but this would probably require a major version bump since some developers may depend on interacting with the DB files directly for some reason.