I am working with documents compiled by Rakudo Perl and the documents can get updated.
I store the documents in a CompUnit::PrecompilationStore::File
How do I change an older version for a newer one?
The following program produces the same output, as if the newer version is not stored in CompUnit. What am I doing wrong?
use v6.c;
use nqp;
'cache'.IO.unlink if 'cache'.IO ~~ e;
my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix=>'cache'.IO);
my $precomp = CompUnit::PrecompilationRepository::Default.new(store=> $precomp-store );
my $key = nqp::sha1('test.pod6');
'test.pod6'.IO.spurt(q:to/--END--/);
=begin pod
=TITLE More and more
Some text
=end pod
--END--
$precomp.precompile('test.pod6'.IO, $key, :force);
my $handle = $precomp.load( $key )[0];
my $resurrected = nqp::atkey($handle.unit,'$=pod')[0];
say $resurrected.contents[1].contents[0];
'test.pod6'.IO.spurt(q:to/--END--/);
=begin pod
=TITLE More and more
Some more text added
=end pod
--END--
# $precomp-store.unlock;
# fails with:
# Attempt to unlock mutex by thread not holding it
# in block <unit> at comp-test.p6 line 30
$precomp.precompile('test.pod6'.IO, $key, :force);
my $new-handle = $precomp.load($key)[0];
my $new-resurrected = nqp::atkey($new-handle.unit,'$=pod')[0];
say $new-resurrected.contents[1].contents[0];
The output is always:
Some text
Some text
Update: My original question had '$handle' not '$new-handle' where '$new-resurrected' is defined. There is no change to the output.