From 714acb5a1500239e6c968254ba4448c35e047c8f Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 10 Apr 2026 22:09:15 +0800 Subject: wip: index streamer. --- vcx | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/vcx b/vcx index b68d28d..17648a9 100644 --- a/vcx +++ b/vcx @@ -329,7 +329,7 @@ sub hash_file_content { return $sha->hexdigest; } -sub get_dir_scanner { +sub dir_streamer { my (@paths) = @_; my $chunk_size = 1024 * 64; # 64 KB chunks for IO buffering @@ -352,13 +352,12 @@ sub get_dir_scanner { print $tmp_fh @buf; @buf = (); $buf_size = 0; - } + }; my @stack = @paths; while (@stack) { my $path = (pop @stack) =~ s|^\./||r; my @st = lstat($path); - if (-d _) { if (opendir(my $dh, $path)) { push @stack, map { File::Spec->catfile($path, $_) } @@ -394,7 +393,7 @@ sub get_dir_scanner { chomp $line; my ($p, $s, $m) = split(/\t/, $line); return { path => $p, size => $s, mtime => $m }; - } + }; } else { $flush->() if @buffer; # Clear remaining close $tmp_fh; @@ -412,6 +411,29 @@ sub get_dir_scanner { chomp $line; my ($p, $s, $m) = split(/\t/, $line); return { path => $p, size => $s, mtime => $m }; - } + }; } } + +sub index_streamer { + $index = INDEX; + open(my $fh, "<:utf8", $index) or die "Could not open index: $!"; + + return sub { + my $line = <$fh>; + unless (defined $line) { + close $fh; + return; + } + + chomp $line; + my ($path, $size, $mtime, $hash) = split(/\t/, $line); + + return { + path => $path, + size => $size, + mtime => $mtime, + hash => $hash, + }; + }; +} -- cgit v1.2.3