Skip to content

Commit

Permalink
don't read from empty cache files
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jun 22, 2011
1 parent e2794cb commit 6980af5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/WebService/Libris/FileCache.pm
Expand Up @@ -20,7 +20,9 @@ sub get {
my ($self, $key) = @_;
my $filename = $self->_filename($key);
return unless open my $h, '<', $filename;
Mojo::DOM->new(xml => 1, charset => 'UTF-8')->parse(do { local $/; <$h> });
my $contents = do { local $/; <$h> };
return unless length $contents;
Mojo::DOM->new(xml => 1, charset => 'UTF-8')->parse($contents);
}

sub set {
Expand Down

0 comments on commit 6980af5

Please sign in to comment.