Skip to content

Commit

Permalink
fixed read-only file system compatibility of Mojo::Asset::File
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 18, 2014
1 parent 0845559 commit 04aa323
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.52 2014-10-18
- Fixed read-only file system compatibility of Mojo::Asset::File.

5.51 2014-10-17
- Fixed bug in Mojolicious::Validator::Validation where every_param would
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Asset/File.pm
Expand Up @@ -17,8 +17,7 @@ has handle => sub {
my $handle = IO::File->new;
my $path = $self->path;
if (defined $path && -f $path) {
$handle->open($path, -w _ ? O_APPEND | O_RDWR : O_RDONLY)
or croak qq{Can't open file "$path": $!};
$handle->open($path, O_RDONLY) or croak qq{Can't open file "$path": $!};
return $handle;
}

Expand Down
12 changes: 0 additions & 12 deletions t/mojo/asset.t
Expand Up @@ -193,18 +193,6 @@ ok !$asset->is_file, 'stored in memory';
$asset = $asset->add_chunk('lala');
ok !$asset->is_file, 'stored in memory';

# Append to file asset
$file = Mojo::Asset::File->new(cleanup => 0);
is $file->add_chunk('hello')->slurp, 'hello', 'right content';
$path = $file->path;
undef $file;
ok -e $path, 'file still exists';
$file = Mojo::Asset::File->new(path => $path, cleanup => 1);
is $file->add_chunk(' world')->slurp, 'hello world', 'right content';
is $file->add_chunk('!')->slurp, 'hello world!', 'right content';
undef $file;
ok !-e $path, 'file has been cleaned up';

# Temporary directory
{
my $tmpdir = tempdir CLEANUP => 1;
Expand Down

3 comments on commit 04aa323

@iakuf
Copy link

@iakuf iakuf commented on 04aa323 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the failure of this project ( "https://github.com/iakuf/mojolicious-stream-upload" ). This will cause the failure of this project.

@kraih
Copy link
Member Author

@kraih kraih commented on 04aa323 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iakuf If you have a solution for the read-only file system problem, please don't hesitate to share it with us. #649 (comment)

@iakuf
Copy link

@iakuf iakuf commented on 04aa323 Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus, the default is read-only, by passing parameters to let it be written?

Please sign in to comment.