summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vcx19
1 files changed, 17 insertions, 2 deletions
diff --git a/vcx b/vcx
index 8c68681..404a144 100644
--- a/vcx
+++ b/vcx
@@ -407,17 +407,32 @@ sub stream_tree {
}
sub stream_index {
- $index = INDEX;
- open(my $fh, "<:utf8", $index) or die "Could not open index: $!";
+ my $index = INDEX;
+ my $offset_len = 8;
+
+ return sub { return; } unless -e $index && -s $index > $offset_len;
+
+ open(my $fh, "<:raw", $index) or die "Could not open index: $!";
+
+ my $file_size = -s $index_path;
+ seek($fh, $file_size - $offset_len, 0);
+ read($fh, my $buf, $offset_len);
+ my $offset = unpack("Q", $buf);
+ seek($fh, $offset, 0);
return sub {
+ my $pos = tell($fh);
+ return if $pos >= ($file_size - $offset_len);
+
my $line = <$fh>;
unless (defined $line) {
close $fh;
return;
}
+
chomp $line;
my ($path, $size, $mtime, $hash) = split(/\t/, $line);
+
return {
path => $path,
size => $size,