isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
3.97k stars 393 forks source link

iOS only: hive with encryption clearing database, app includes db usage in background #1276

Open neiljaywarner opened 5 months ago

neiljaywarner commented 5 months ago

Has anyone ever experienced this? I will try to get an MVCE but i wanted to throw it out here before i forget because this is where "Get help" from the documentation went. :)

from pubspec.lock

mac app uses Timer() to have db access every x minutes iOS app uses https://pub.dev/packages/flutter_background_geolocation for db access when location changes.

ig-garcia commented 3 months ago

I did a test project and this happened to me the other way. I opened an encrypted box and stored some values, then next time I opened the box without encryption and when I check the box.values they are empty.

Is this expected in any way? I was expecting that I could check whether the db is encrypted by getting some garbage data. Even if I open the box with encryption again, it is always empty after first time.

neiljaywarner commented 3 months ago

We worked with this a long long time because of iOS and Flutter secure storage

Hive should have better documentation around this and throw an exception rather than corrupt/delete data IMHO but I guess they just consider it your responsibility to use the right key. Your use case sounds a little different but similar. I suspect it is expected behavior. There probably isn't any way to know if the box is encrypted any more than knowing if you have the right key

I mean unless of course you know the filename and put the file in a string. It's "just" a file right?

....sent from my phone

On Tue, Apr 2, 2024, 6:07 AM ig-garcia @.***> wrote:

I did a test project and this happened to me the other way. I opened an encrypted box and stored some values, then next time I opened the box without encryption and when I check the box.values they are empty.

Is this expected in any way? I was expecting that I could check whether the db is encrypted by getting some garbage data.

— Reply to this email directly, view it on GitHub https://github.com/isar/hive/issues/1276#issuecomment-2031718836, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXBGYONJE2J6CDNSLYPSV3Y3KGQ5AVCNFSM6AAAAABDMSUQOOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZRG4YTQOBTGY . You are receiving this because you authored the thread.Message ID: @.***>