projects
/
perl-cwmp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
re-enable all_parameteres collection of first connect
[perl-cwmp.git]
/
lib
/
CWMP
/
Store
/
HASH.pm
diff --git
a/lib/CWMP/Store/HASH.pm
b/lib/CWMP/Store/HASH.pm
index
87bec30
..
5b15fcc
100644
(file)
--- a/
lib/CWMP/Store/HASH.pm
+++ b/
lib/CWMP/Store/HASH.pm
@@
-3,6
+3,11
@@
package CWMP::Store::HASH;
use strict;
use warnings;
use strict;
use warnings;
+use Exporter 'import';
+our @EXPORT = qw/
+ $debug
+/;
+
use Data::Dump qw/dump/;
use Hash::Merge qw/merge/;
use Carp qw/confess/;
use Data::Dump qw/dump/;
use Hash::Merge qw/merge/;
use Carp qw/confess/;
@@
-27,6
+32,8
@@
my $path;
my $debug = 0;
my $debug = 0;
+my $cleaned = 0;
+
sub open {
my $self = shift;
sub open {
my $self = shift;
@@
-42,12
+49,13
@@
sub open {
if ( ! -e $path ) {
mkdir $path || die "can't create $path: $!";
warn "created $path directory\n" if $debug;
if ( ! -e $path ) {
mkdir $path || die "can't create $path: $!";
warn "created $path directory\n" if $debug;
- } elsif ( $args->{clean} ) {
+ } elsif ( $args->{clean}
&& ! $cleaned
) {
warn "removed old $path\n" if $debug;
foreach my $uid ( $self->all_uids ) {
my $file = $self->file( $uid );
unlink $file || die "can't remove $file: $!";
}
warn "removed old $path\n" if $debug;
foreach my $uid ( $self->all_uids ) {
my $file = $self->file( $uid );
unlink $file || die "can't remove $file: $!";
}
+ $cleaned++;
}
}
@@
-93,6
+101,20
@@
sub get_state {
return;
}
return;
}
+
+=head2 set_state
+
+ $store->set_state( $uid, $state );
+
+=cut
+
+sub set_state {
+ my ( $self, $uid, $state ) = @_;
+ my $file = $self->file( $uid );
+ return $self->save_hash( $file, $state );
+}
+
+
=head2 all_uids
my @uids = $store->all_uids;
=head2 all_uids
my @uids = $store->all_uids;
@@
-103,7
+125,7
@@
sub all_uids {
my $self = shift;
my $ext = $self->extension;
my $self = shift;
my $ext = $self->extension;
- warn "## extension: $ext";
+
#
warn "## extension: $ext";
opendir(my $d, $path) || die "can't opendir $path: $!";
my @uids = grep { $_ =~ m/\Q$ext\E$/ && -f "$path/$_" } readdir($d);
opendir(my $d, $path) || die "can't opendir $path: $!";
my @uids = grep { $_ =~ m/\Q$ext\E$/ && -f "$path/$_" } readdir($d);