Skip Menu |

This queue is for tickets about the Catalyst-Model-File CPAN distribution.

Report information
The Basics
Id: 41424
Status: resolved
Priority: 0/
Queue: Catalyst-Model-File

People
Owner: Nobody in particular
Requestors: depesz [...] depesz.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.06
Fixed in: 0.07



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
please find attached test file which shows the problem.
use strict; use warnings; use Test::More; plan tests => 5; use FindBin; use lib "$FindBin::Bin/lib"; $ENV{MODEL_FILE_DIR} = $FindBin::Bin . '/store'; { require Path::Class; Path::Class::dir($ENV{MODEL_FILE_DIR})->rmtree; } use_ok('Catalyst::Model::File'); use_ok('TestApp'); ok(-d $ENV{MODEL_FILE_DIR}, 'Store directory exists'); open my $fh, '>>', $ENV{MODEL_FILE_DIR} . '/foo1'; print $fh '1234'; close $fh; my $model = TestApp->model('File'); my @files_from_model = sort $model->list( 'mode' => 'files' ); use Data::Dumper; for my $file (@files_from_model) { my $st = $file->stat; ok(defined $st && $st->isa('File::stat'), 'Stat works on file from model'); ok(defined $st && $st->size == 4, 'Got correct size from stat'); } $model->{root_dir}->rmtree;
I actually fixed this bug when ever i released 0.07 - just forgot to update the ticket.