Subject: | stat doesn't work for listed files? |
I have request handler which looks like:
sub history : Local {
my ( $self, $c ) = @_;
my @files = $c->model('File')->list(
'mode' => 'files',
'recurse' => 0,
);
use Data::Dumper;
for my $file (@files) {
print Dumper($file);
print $file->basename . "\n";
print $file->absolute . "\n";
my $x = $file->stat();
print Dumper($x);
}
$c->stash->{'files'} = \@files;
return;
}
the problem - $x ($file->stat) is undef:
$VAR1 = bless( {
'file_spec_class' => undef,
'file' => 'sI',
'dir' => undef
}, 'Path::Class::File' );
sI
/home/depesz/projects/Explain_Depesz_Com/sI
$VAR1 = undef;
$VAR1 = bless( {
'file_spec_class' => undef,
'file' => 'wj',
'dir' => undef
}, 'Path::Class::File' );
wj
/home/depesz/projects/Explain_Depesz_Com/wj
$VAR1 = undef;
$VAR1 = bless( {
'file_spec_class' => undef,
'file' => '8A',
'dir' => undef
}, 'Path::Class::File' );
8A
/home/depesz/projects/Explain_Depesz_Com/8A
$VAR1 = undef;
$VAR1 = bless( {
'file_spec_class' => undef,
'file' => 'G7',
'dir' => undef
}, 'Path::Class::File' );
G7
/home/depesz/projects/Explain_Depesz_Com/G7
$VAR1 = undef;
I was able to make a workaround this, by changing $x = $file->stat into:
my $x = $c->model('File')->file($file)->stat();
but it's hardly intuitive.
strace shows that when calling ->stat() system calls stat on file "G7"
in current directory, not in absolute directory, but when i tried to
replicate it using Path::Class directly - everything worked.
Important modules versions:
=> modver Path::Class
Version 0.16
=> modver Catalyst
Version 5.7014
=> modver Catalyst::Model::File
Version 0.06