From b247739b72049d60f691fa72e67885d94e185434 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 26 Oct 2007 21:41:42 +0000 Subject: [PATCH] use Hash::Merge to correctly handle update, This might actually move to Store, but this way plugins get only new state... git-svn-id: https://perl-cwmp.googlecode.com/svn/branches/store-pluggable@138 836a5e1a-633d-0410-964b-294494ad4392 --- Makefile.PL | 2 ++ lib/CWMP/Store/YAML.pm | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile.PL b/Makefile.PL index 2901ef7..80aaafd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -19,6 +19,8 @@ requires 'DBM::Deep'; requires 'Getopt::Long'; requires 'Term::Shelly' => '0.03'; requires 'Module::Pluggable'; +requires 'YAML'; +requires 'Hash::Merge'; build_requires 'Test::More'; diff --git a/lib/CWMP/Store/YAML.pm b/lib/CWMP/Store/YAML.pm index 9805a50..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: $!"; } -- 2.20.1