more correctly restore path with external file
[dbsrgits/DBIx-Class-Fixtures.git] / lib / DBIx / Class / Fixtures / External / File.pm
index 97fd5fb..4277e7b 100644 (file)
@@ -3,7 +3,8 @@ package DBIx::Class::Fixtures::External::File;
 use strict;
 use warnings;
 
-use File::Spec::Functions 'catfile';
+use File::Spec::Functions 'catfile', 'splitpath';
+use File::Path 'mkpath';
 
 sub _load {
   my ($class, $path) = @_;
@@ -29,7 +30,9 @@ sub backup {
 
 sub restore {
   my ($class, $key, $content, $args) = @_;
-  my $path = catfile($args->{path}, $key);
+  my ($vol, $directory, $file) = splitpath catfile($args->{path}, $key);
+  mkpath($directory) unless -d $directory;
+  my $path = catfile($vol, $directory, $file);
   $class->_save($path, $content);
 }