Skip Menu |

This queue is for tickets about the DBIx-Class-InflateColumn-FS CPAN distribution.

Report information
The Basics
Id: 109082
Status: new
Priority: 0/
Queue: DBIx-Class-InflateColumn-FS

People
Owner: Nobody in particular
Requestors: DAVEWOOD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: passing anonymous or File::Temp filehandle results in empty file.
in my perl code i have a string with the content that i want to pass to DBIC::IC::FS. if I get a anonymous fh to a temp array or if I use File::Temp the resulting file that is created by DBIC::IC::FS is empty. here are 2 failing tests describing the issue.
Subject: 20-scalar_fh.t
#!perl use warnings; use strict; use DBICx::TestDatabase; use Test::More tests => 2; use lib qw(t/lib); my $schema = DBICx::TestDatabase->new('My::TestSchema'); my $rs = $schema->resultset('Book'); # we'll use a filehandle to a scalar as our content my $string = "moo\nmee\nmaa"; open( my $string_fh, '<', \$string) or die "Could not open for reading."; my $book = $rs->create({ name => 'Alice in Wonderland', cover_image => $string_fh, }); isa_ok( $book->cover_image, 'Path::Class::File' ); my $fh = $book->cover_image->open('r'); my @lines = <$fh>; is( scalar @lines, 3, 'file has 3 lines' );
Subject: 21-temp_file.t
#!perl use warnings; use strict; use DBICx::TestDatabase; use Test::More tests => 2; use File::Temp; use lib qw(t/lib); my $schema = DBICx::TestDatabase->new('My::TestSchema'); my $rs = $schema->resultset('Book'); # we'll use a temp file handle as our content my $string = "moo\nmee\nmaa"; my $tmp_fh = File::Temp->new( UNLINK => 1 ); print $tmp_fh $string; # test passes when the next two lines are executed #$tmp_fh->close; #open ($tmp_fh, "<", "$tmp_fh") or die "Cant open for reading: $!"; my $book = $rs->create({ name => 'Alice in Wonderland', cover_image => $tmp_fh, }); isa_ok( $book->cover_image, 'Path::Class::File' ); my $fh = $book->cover_image->open('r'); my @lines = <$fh>; is( scalar @lines, 3, 'file has 3 lines' );
prove output david@dry:~/dev/DBIx-Class-InflateColumn-FS-0.01007$ prove -lvr t/20-scalar_fh.t t/20-scalar_fh.t .. 1..2 ok 1 - An object of class 'Path::Class::File' isa 'Path::Class::File' not ok 2 - file has 3 lines # Failed test 'file has 3 lines' # at t/20-scalar_fh.t line 24. # got: '0' # expected: '3' # Looks like you failed 1 test of 2. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/2 subtests Test Summary Report ------------------- t/20-scalar_fh.t (Wstat: 256 Tests: 2 Failed: 1) Failed test: 2 Non-zero exit status: 1 Files=1, Tests=2, 1 wallclock secs ( 0.05 usr 0.01 sys + 0.65 cusr 0.05 csys = 0.76 CPU) Result: FAIL david@dry:~/dev/DBIx-Class-InflateColumn-FS-0.01007$ prove -lvr t/21-temp_file.t t/21-temp_file.t .. 1..2 ok 1 - An object of class 'Path::Class::File' isa 'Path::Class::File' not ok 2 - file has 3 lines # Failed test 'file has 3 lines' # at t/21-temp_file.t line 30. # got: '0' # expected: '3' # Looks like you failed 1 test of 2. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/2 subtests Test Summary Report ------------------- t/21-temp_file.t (Wstat: 256 Tests: 2 Failed: 1) Failed test: 2 Non-zero exit status: 1 Files=1, Tests=2, 1 wallclock secs ( 0.05 usr 0.01 sys + 0.64 cusr 0.06 csys = 0.76 CPU) Result: FAIL
I can get t/21-temp_file.t to pass if I do seek $tmp_fh, 0, 0; before passing to DBIC::IC::FS my $string = "moo\nmee\nmaa"; my $tmp_fh = File::Temp->new( UNLINK => 1 ); print $tmp_fh $string; seek $tmp_fh, 0, 0; my $book = $rs->create({ name => 'Alice in Wonderland', cover_image => $tmp_fh, });
20:06 < semifor> davewood: IC::FS uses File::Copy in deflate. It doesn't seem to like filehandles on scalar refs, unfortunately.