X-Git-Url: http://git.rot13.org/?p=perl-cwmp.git;a=blobdiff_plain;f=lib%2FCWMP%2FStore%2FYAML.pm;h=160cbe88f9c4f218d91a33dbff7931caed4c5a62;hp=588060fd320144df16c6158ae0c96f8f36c523b8;hb=b247739b72049d60f691fa72e67885d94e185434;hpb=5932049f4e38bb24ce33fedc7574ef1988099618 diff --git a/lib/CWMP/Store/YAML.pm b/lib/CWMP/Store/YAML.pm index 588060f..160cbe8 100644 --- a/lib/CWMP/Store/YAML.pm +++ b/lib/CWMP/Store/YAML.pm @@ -6,6 +6,7 @@ use warnings; use Data::Dump qw/dump/; use YAML qw/LoadFile DumpFile/; +use Hash::Merge qw/merge/; =head1 NAME @@ -44,7 +45,13 @@ sub update_uid_state { my $file = "$dir/$uid.yml"; - DumpFile( $file, $state ) || die "can't write $file: $!"; + my $old_state = $self->get_state( $uid ); + + my $combined = merge( $state, $old_state ); + +# warn "## ",dump( $old_state, $state, $combined ); + + DumpFile( $file, $combined ) || die "can't write $file: $!"; } @@ -79,7 +86,7 @@ sub all_uids { my @uids = grep { /\.yml$/ && -f "$dir/$_" } readdir($d); closedir $d; - return map { s/\.yml$// } @uids; + return map { my $l = $_; $l =~ s/\.yml$//; $l } @uids; } 1;