summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-04-11 23:10:40 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-04-11 23:10:40 +0800
commiteb6446878b28ad53064dffa1f7eb09d55bbb8cdd (patch)
tree5063b37c276306aa59a5d31752b81efb991a6a4f
parente7abc837c72f966bd51a07bab90d8520eda1d917 (diff)
downloadcvn-eb6446878b28ad53064dffa1f7eb09d55bbb8cdd.tar.gz
wip: read paged index.
-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,