X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FDumper%2FV4.pm;h=d3381b6516bb9185db0d9bddbfa762ebcf4ea37d;hb=c98fc7d0294e641cf8844306808333bdec4fea2f;hp=81002128139c714b10b5b626ef09d32bf818b511;hpb=50f1a929d9224b9072b5fae39162a5d943323c5d;p=chaz%2Fp5-File-KDBX diff --git a/lib/File/KDBX/Dumper/V4.pm b/lib/File/KDBX/Dumper/V4.pm index 8100212..d3381b6 100644 --- a/lib/File/KDBX/Dumper/V4.pm +++ b/lib/File/KDBX/Dumper/V4.pm @@ -11,17 +11,17 @@ use File::KDBX::Constants qw(:header :inner_header :compression :kdf :variant_ma use File::KDBX::Error; use File::KDBX::IO::Crypt; use File::KDBX::IO::HmacBlock; -use File::KDBX::Util qw(:empty assert_64bit erase_scoped); +use File::KDBX::Util qw(:class :empty :load assert_64bit erase_scoped); use IO::Handle; use Scalar::Util qw(looks_like_number); use boolean qw(:all); use namespace::clean; -use parent 'File::KDBX::Dumper'; +extends 'File::KDBX::Dumper'; our $VERSION = '999.999'; # VERSION -sub _binaries_written { $_[0]->{_binaries_written} //= {} } +has _binaries_written => {}, is => 'ro'; sub _write_headers { my $self = shift; @@ -61,7 +61,7 @@ sub _write_header { my $type = shift; my $val = shift // ''; - $type = KDBX_HEADER($type); + $type = to_header_constant($type); if ($type == HEADER_END) { # nothing } @@ -243,7 +243,7 @@ sub _write_body { my $compress = $kdbx->headers->{+HEADER_COMPRESSION_FLAGS}; if ($compress == COMPRESSION_GZIP) { - require IO::Compress::Gzip; + load_optional('IO::Compress::Gzip'); $fh = IO::Compress::Gzip->new($fh, -Level => IO::Compress::Gzip::Z_BEST_COMPRESSION(), -TextFlag => 1, @@ -289,8 +289,7 @@ sub _write_inner_header { my $buf = pack('C', $type); $fh->print($buf) or throw 'Failed to write inner header type'; - $type = KDBX_INNER_HEADER($type); - + $type = to_inner_header_constant($type); if ($type == INNER_HEADER_END) { # nothing } @@ -318,8 +317,8 @@ sub _write_binaries { my $new_ref = 0; my $written = $self->_binaries_written; - my $entries = $kdbx->all_entries(history => true); - for my $entry (@$entries) { + my $entries = $kdbx->entries(history => 1); + while (my $entry = $entries->next) { for my $key (keys %{$entry->binaries}) { my $binary = $entry->binaries->{$key}; if (defined $binary->{ref} && defined $kdbx->binaries->{$binary->{ref}}) {