Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't create empty slabs

  • Loading branch information...
commit 1778b46082c58bab78cf0b2d0496f471b1aa7b2c 1 parent afc0853
David Leadbeater authored
Showing with 11 additions and 9 deletions.
  1. +4 −4 lib/WWW/CPANGrep/Slab/Writer.pm
  2. +7 −5 lib/WWW/CPANGrep/Slabs.pm
8 lib/WWW/CPANGrep/Slab/Writer.pm
View
@@ -39,7 +39,7 @@ has seen_dists => (
default => sub { {} },
);
-has _size => (
+has size => (
is => 'rw',
isa => 'Int',
default => 0,
@@ -76,7 +76,7 @@ sub index {
print {$self->_fh} $$content, SLAB_SEPERATOR;
- $self->redis->zadd($self->name, $self->_size, encode_json {
+ $self->redis->zadd($self->name, $self->size, encode_json {
size => length($$content),
dist => $dist,
distname => $distname,
@@ -85,12 +85,12 @@ sub index {
$self->{seen_dists}{$distname}++;
- $self->_size($self->_size + length($$content) + length SLAB_SEPERATOR);
+ $self->size($self->size + length($$content) + length SLAB_SEPERATOR);
}
sub full {
my($self) = @_;
- return $self->_size >= $self->rotate_size;
+ return $self->size >= $self->rotate_size;
}
__PACKAGE__->meta->make_immutable;
12 lib/WWW/CPANGrep/Slabs.pm
View
@@ -52,13 +52,15 @@ sub finish {
my $r = (tied %{$self->redis})->{_conn};
- # Tie::Redis won't autovivify yet :(
- $self->redis->{$self->name} ||= [];
+ if($self->_slab->size) {
+ # Tie::Redis won't autovivify yet :(
+ $self->redis->{$self->name} ||= [];
- push @{$self->redis->{$self->name}}, $self->_slab->name;
+ push @{$self->redis->{$self->name}}, $self->_slab->name;
- for my $dist(keys %{$self->_slab->seen_dists}) {
- $r->hset("cpangrep:dists", $dist, $self->_slab->name);
+ for my $dist(keys %{$self->_slab->seen_dists}) {
+ $r->hset("cpangrep:dists", $dist, $self->_slab->name);
+ }
}
$self->_slab(undef);
Please sign in to comment.
Something went wrong with that request. Please try again.