r248@brr: dpavlin | 2007-11-20 14:08:48 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 20 Nov 2007 13:09:08 +0000 (13:09 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 20 Nov 2007 13:09:08 +0000 (13:09 +0000)
 cleanup dump directory on startup

git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@217 836a5e1a-633d-0410-964b-294494ad4392

Makefile.PL
bin/acs.pl

index b317c5f..723073d 100644 (file)
@@ -26,6 +26,7 @@ requires      'IPC::DirQueue';
 requires       'File::Spec';
 requires       'File::Path';
 requires       'Class::Trigger';
 requires       'File::Spec';
 requires       'File::Path';
 requires       'Class::Trigger';
+requires       'File::Find';
 
 build_requires 'Test::More';
 
 
 build_requires 'Test::More';
 
index 3675088..1b341e7 100755 (executable)
@@ -12,6 +12,7 @@ use CWMP::Session;
 use CWMP::Vendor;
 use Getopt::Long;
 use Data::Dump qw/dump/;
 use CWMP::Vendor;
 use Getopt::Long;
 use Data::Dump qw/dump/;
+use File::Find;
 
 my $port = 3333;
 my $debug = 0;
 
 my $port = 3333;
 my $debug = 0;
@@ -27,6 +28,19 @@ GetOptions(
        'create_dump!' => \$create_dump,
 );
 
        'create_dump!' => \$create_dump,
 );
 
+if ( $create_dump ) {
+       warn "## cleaning dump directory\n" if $debug;
+       find({
+               wanted => sub {
+                       my $path = $File::Find::name;
+                       return if -d $path;
+                       unlink($path) || die "can't remove $path: $!";
+                       warn "## removed $path\n" if $debug;
+               },
+               no_chdir => 1,
+       }, 'dump/' );
+}
+
 my $server = CWMP::Server->new({
        port => $port,
        session => {
 my $server = CWMP::Server->new({
        port => $port,
        session => {