Browse Source

fixed bug saving files with history entries which contain attachments.

pull/3/head
Herbert Poul 4 years ago
parent
commit
7788c0fba1
  1. 1
      bin/kdbx.dart
  2. 12
      lib/src/kdbx_entry.dart
  3. 14
      lib/src/kdbx_object.dart
  4. 1
      test/kdbx4_test.dart

1
bin/kdbx.dart

@ -27,7 +27,6 @@ void main(List<String> arguments) {
}
print(error);
exit(64);
return null;
});
// final inputFile = args['input'] as String;

12
lib/src/kdbx_entry.dart

@ -85,6 +85,16 @@ class KdbxEntry extends KdbxObject {
final List<KdbxEntry> 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))

14
lib/src/kdbx_object.dart

@ -75,22 +75,26 @@ abstract class KdbxNode with Changeable<KdbxNode> {
}
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();

1
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';

Loading…
Cancel
Save