From f33ff0a017caee8b408a1b3da710fae14b3ec432 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Sat, 9 May 2020 15:54:19 +0200 Subject: [PATCH] fix saving entries without history. --- lib/src/kdbx_entry.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/src/kdbx_entry.dart b/lib/src/kdbx_entry.dart index 96a7285..5fa56e2 100644 --- a/lib/src/kdbx_entry.dart +++ b/lib/src/kdbx_entry.dart @@ -1,6 +1,3 @@ -import 'dart:convert'; -import 'dart:typed_data'; - import 'package:kdbx/kdbx.dart'; import 'package:kdbx/src/crypto/protected_value.dart'; import 'package:kdbx/src/kdbx_binary.dart'; @@ -38,13 +35,15 @@ class KdbxKey { class KdbxEntry extends KdbxObject { KdbxEntry.create(KdbxFile file, KdbxGroup parent) : isHistoryEntry = false, + history = [], super.create(file, 'Entry', parent) { icon.set(KdbxIcon.Key); } KdbxEntry.read(KdbxReadWriteContext ctx, KdbxGroup parent, XmlElement node, {this.isHistoryEntry = false}) - : super.read(parent, node) { + : history = [], + super.read(parent, node) { _strings.addEntries(node.findElements(KdbxXml.NODE_STRING).map((el) { final key = KdbxKey(el.findElements(KdbxXml.NODE_KEY).single.text); final valueNode = el.findElements(KdbxXml.NODE_VALUE).single; @@ -71,16 +70,16 @@ class KdbxEntry extends KdbxObject { return MapEntry(key, KdbxBinary.readBinaryXml(valueNode, isInline: true)); })); - history = _historyElement + history.addAll(_historyElement .findElements('Entry') .map( (entry) => KdbxEntry.read(ctx, parent, entry, isHistoryEntry: true)) - .toList(); + .toList()); } final bool isHistoryEntry; - List history; + final List history; XmlElement get _historyElement => node .findElements(KdbxXml.NODE_HISTORY)