Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed small caching bug in Morbo file watcher
  • Loading branch information
kraih committed Mar 6, 2012
1 parent bea10d0 commit a920d72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@ This file documents the revision history for Perl extension Mojolicious.

2.58 2012-03-06 00:00:00
- Improved documentation.
- Fixed small caching bug in Morbo file watcher.

2.57 2012-03-03 00:00:00
- Replaced protection from excessively large form values in
Expand Down
10 changes: 4 additions & 6 deletions lib/Mojo/Server/Morbo.pm
Expand Up @@ -11,9 +11,6 @@ use constant DEBUG => $ENV{MORBO_DEBUG} || 0;
has listen => sub { [] };
has watch => sub { [qw/lib templates/] };

# Cache stats
my $STATS = {};

# "All in all, this is one day Mittens the kitten won’t soon forget.
# Kittens give Morbo gas.
# In lighter news, the city of New New York is doomed.
Expand All @@ -25,9 +22,10 @@ sub check_file {
# Check if modify time and/or size have changed
my ($size, $mtime) = (stat $file)[7, 9];
return unless defined $mtime;
my $stats = $STATS->{$file} ||= [$^T, $size];
my $cache = $self->{cache} ||= {};
my $stats = $cache->{$file} ||= [$^T, $size];
return if $mtime <= $stats->[0] && $size == $stats->[1];
$STATS->{$file} = [$mtime, $size];
$cache->{$file} = [$mtime, $size];

return 1;
}
Expand Down Expand Up @@ -182,7 +180,7 @@ the following new ones.
=head2 C<check_file>
$morbo->check_file('script/myapp');
my $success = $morbo->check_file('/home/sri/lib/MyApp.pm');
Check if file has been modified since last check.
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojolicious.pm
Expand Up @@ -31,9 +31,8 @@ has sessions => sub { Mojolicious::Sessions->new };
has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $AUTHORITY = 'cpan:SRI';
our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.58';
our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.58';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down

0 comments on commit a920d72

Please sign in to comment.