Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
When installing, save a snapshot of that project's metainfo into the …
…statefile
  • Loading branch information
Geoffrey Broadwell committed Aug 16, 2012
1 parent f6b9fde commit 2ba908f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Panda/Ecosystem.pm
Expand Up @@ -7,6 +7,7 @@ class Panda::Ecosystem does Pies::Ecosystem {
has $.projectsfile;
has %!projects;
has %!states;
has %!saved-meta;

sub getfile($src, $dest) {
pir::load_bytecode__vs('LWP/UserAgent.pir');
Expand Down Expand Up @@ -41,7 +42,8 @@ class Panda::Ecosystem does Pies::Ecosystem {
method flush-states {
my $fh = open($!statefile, :w);
for %!states.kv -> $key, $val {
$fh.say: "$key $val";
my $json = to-json %!saved-meta{$key};
$fh.say: "$key $val $json";
}
$fh.close;
}
Expand All @@ -50,8 +52,9 @@ class Panda::Ecosystem does Pies::Ecosystem {
if $!statefile.IO ~~ :f {
my $fh = open($!statefile);
for $fh.lines -> $line {
my ($mod, $state) = split ' ', $line;
my ($mod, $state, $json) = split ' ', $line, 3;
%!states{$mod} = $state;
%!saved-meta{$mod} = from-json $json;
}
}

Expand Down Expand Up @@ -95,9 +98,14 @@ class Panda::Ecosystem does Pies::Ecosystem {
%!states{$p.name} // 'absent'
}

method project-get-saved-meta(Pies::Project $p) {
%!saved-meta{$p.name};
}

method project-set-state(Pies::Project $p,
Pies::Project::State $s) {
%!states{$p.name} = $s;
%!saved-meta{$p.name} = $p.metainfo;
self.flush-states;
}
}
Expand Down

0 comments on commit 2ba908f

Please sign in to comment.