use File::Path mkpath to create export directories
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 6 Jun 2010 12:14:02 +0000 (14:14 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 6 Jun 2010 12:14:02 +0000 (14:14 +0200)
Makefile.PL
lib/MojoFacets/Data.pm

index 1cf9266..34a5af7 100755 (executable)
@@ -20,6 +20,7 @@ WriteMakefile(
                'File::Slurp' => 0,
                'JSON' => 0,
                'HTML::TableExtract' => 0,
                'File::Slurp' => 0,
                'JSON' => 0,
                'HTML::TableExtract' => 0,
+               'File::Path' => 0,
        },
     test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'}
 );
        },
     test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'}
 );
index 5b26968..1afa188 100644 (file)
@@ -12,6 +12,7 @@ use locale;
 use File::Find;
 use Storable;
 use Time::HiRes qw(time);
 use File::Find;
 use Storable;
 use Time::HiRes qw(time);
+use File::Path qw(mkpath);
 
 use MojoFacets::Import::File;
 use MojoFacets::Import::HTMLTable;
 
 use MojoFacets::Import::File;
 use MojoFacets::Import::HTMLTable;
@@ -289,11 +290,9 @@ sub _permanent_path {
 
 sub _export_path {
        my $self = shift;
 
 sub _export_path {
        my $self = shift;
-       my $path = $self->_param_or_session('path');
-       my $dir = $self->app->home->rel_dir('public') . '/export/';
-       mkdir $dir unless -e $dir;
-       $dir .= $path;
-       mkdir $dir unless -e $dir;
+       my $path = $self->_param_or_session('path') || die "no path";
+       my $dir = $self->app->home->rel_dir('public') . "/export/$path";
+       mkpath $dir unless -e $dir;
        $dir . '/' . join('.', @_);
 }
 
        $dir . '/' . join('.', @_);
 }