Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Oct 18, 2019
1 parent 025bc51 commit 4179585
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions hive/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0+3

### Fixes
- Fixed bug where `object.save()` would faild on subsequent calls

## 1.1.0+2

### Fixes
Expand Down
3 changes: 2 additions & 1 deletion hive/lib/src/box/keystore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class Keystore<E> {

if (deletedFrame != null) {
_deletedEntries++;
if (deletedFrame.value is HiveObject) {
if (deletedFrame.value is HiveObject &&
!identical(deletedFrame.value, frame.value)) {
unloadHiveObject(deletedFrame.value as HiveObject);
}
}
Expand Down
2 changes: 1 addition & 1 deletion hive/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: hive
description: Lightweight and blazing fast key-value database written in pure Dart. Stronly encrypted using AES-256.
version: 1.1.0+2
version: 1.1.0+3
author: Simon Leier <[email protected]>
homepage: https://github.com/hivedb/hive

Expand Down
14 changes: 13 additions & 1 deletion hive/test/keystore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,26 @@ void main() {
var box = BoxMock();
var keystore = Keystore.debug(box: box);

var hiveObject = HiveObjectMock();
var hiveObject = _TestHiveObject();
keystore.insert(Frame('key', hiveObject));
keystore.insert(Frame('key', HiveObjectMock()));

expect(hiveObject.key, null);
expect(hiveObject.box, null);
});

test('does not unload HiveObject if it is the same instance', () {
var box = BoxMock();
var keystore = Keystore.debug(box: box);

var hiveObject = _TestHiveObject();
keystore.insert(Frame('key', hiveObject));
keystore.insert(Frame('key', hiveObject));

expect(hiveObject.key, 'key');
expect(hiveObject.box, box);
});

test('increases deletedEntries', () {
var keystore = Keystore.debug();
expect(keystore.deletedEntries, 0);
Expand Down

0 comments on commit 4179585

Please sign in to comment.