diff --git a/bin/kdbx.dart b/bin/kdbx.dart index 8df3366..8668e72 100644 --- a/bin/kdbx.dart +++ b/bin/kdbx.dart @@ -27,7 +27,6 @@ void main(List arguments) { } print(error); exit(64); - return null; }); // final inputFile = args['input'] as String; diff --git a/lib/src/kdbx_entry.dart b/lib/src/kdbx_entry.dart index fb769f7..014c2b3 100644 --- a/lib/src/kdbx_entry.dart +++ b/lib/src/kdbx_entry.dart @@ -85,6 +85,16 @@ class KdbxEntry extends KdbxObject { final List history; + @override + set file(KdbxFile file) { + super.file = file; + // TODO this looks like some weird workaround, get rid of the + // `file` reference. + for (final historyEntry in history) { + historyEntry.file = file; + } + } + XmlElement get _historyElement => node .findElements(KdbxXml.NODE_HISTORY) .singleWhere((_) => true, orElse: () { @@ -132,7 +142,7 @@ class KdbxEntry extends KdbxObject { if (binary.isInline) { binary.saveToXml(value); } else { - final binaryIndex = file.ctx.findBinaryId(binary); + final binaryIndex = ctx.findBinaryId(binary); value.addAttribute(KdbxXml.ATTR_REF, binaryIndex.toString()); } return XmlElement(XmlName(KdbxXml.NODE_BINARY)) diff --git a/lib/src/kdbx_object.dart b/lib/src/kdbx_object.dart index 52197a9..6bf7b63 100644 --- a/lib/src/kdbx_object.dart +++ b/lib/src/kdbx_object.dart @@ -75,22 +75,26 @@ abstract class KdbxNode with Changeable { } abstract class KdbxObject extends KdbxNode { - KdbxObject.create( - KdbxReadWriteContext ctx, this.file, String nodeName, KdbxGroup parent) - : times = KdbxTimes.create(ctx), + KdbxObject.create(this.ctx, this.file, String nodeName, KdbxGroup parent) + : assert(ctx != null), + times = KdbxTimes.create(ctx), _parent = parent, super.create(nodeName) { _uuid.set(KdbxUuid.random()); } - KdbxObject.read(KdbxReadWriteContext ctx, KdbxGroup parent, XmlElement node) - : times = KdbxTimes.read(node.findElements('Times').single, ctx), + KdbxObject.read(this.ctx, KdbxGroup parent, XmlElement node) + : assert(ctx != null), + times = KdbxTimes.read(node.findElements('Times').single, ctx), _parent = parent, super.read(node); /// the file this object is part of. will be set AFTER loading, etc. + /// TODO: We should probably get rid of this `file` reference. KdbxFile file; + final KdbxReadWriteContext ctx; + final KdbxTimes times; KdbxUuid get uuid => _uuid.get(); diff --git a/test/kdbx4_test.dart b/test/kdbx4_test.dart index dfa24f1..0adac0d 100644 --- a/test/kdbx4_test.dart +++ b/test/kdbx4_test.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:kdbx/kdbx.dart'; import 'package:kdbx/src/kdbx_header.dart'; import 'package:logging/logging.dart';