- added clean parametar to stores to start with empty database
[perl-cwmp.git] / lib / CWMP / Store / DBMDeep.pm
index 985a124..04e4959 100644 (file)
@@ -16,11 +16,17 @@ CWMP::Store::DBMDeep - use DBM::Deep as storage
 
 =head2 open
 
+  $store->open({
+       path => 'var/',
+       debug => 1,
+       clean => 1,
+  });
+
 =cut
 
 my $db;
 
-my $debug = 1;
+my $debug = 0;
 
 sub open {
        my $self = shift;
@@ -34,6 +40,11 @@ sub open {
 
        $path = "$path/state.db" if ( -d $args->{path} );
 
+       if ( $args->{clean} && -e $path ) {
+               warn "removed old $path\n";
+               unlink $path || die "can't remove $path: $!";
+       }
+
        $db = DBM::Deep->new(
                file => $path,
                locking => 1,