summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-12-28 20:00:33 +0000
committerSean Whitton <spwhitton@spwhitton.name>2019-12-28 20:00:33 +0000
commit01f3f1c216cea581fd9efd850aa781520dda3729 (patch)
tree3a7caa044fc0761c395faf3401dbd43da5556a65 /lib
parent9e13729aa6cec86d8b239c81a50c083ad6a9ba80 (diff)
downloaddotfiles-01f3f1c216cea581fd9efd850aa781520dda3729.tar.gz
fix caching
Diffstat (limited to 'lib')
-rw-r--r--lib/perl5/Local/MrRepo/Repo/Git/Annex.pm22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm b/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm
index e17de666..03f9b6a1 100644
--- a/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm
+++ b/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm
@@ -23,7 +23,7 @@ use parent 'Local::MrRepo::Repo::Git';
use Data::Compare;
use Exporter 'import';
-use File::Spec::Functions qw(rel2abs);
+use File::Spec::Functions qw(rel2abs catfile);
use Git::Wrapper;
use JSON;
use Local::ScriptStatus;
@@ -201,12 +201,12 @@ sub review_unused {
sub unused_files {
my ($self, $unused_args) = @_;
- my $annex_dir = $self->git_path("annex");
- my $cache_file = catfile($annex_dir, "unused_info");
+ my $cache_file = $self->_unused_cache_file;
$self->{_unused_files} //= retrieve($cache_file) if -e $cache_file;
# see if cached result needs to be invalidated
if (defined $self->{_unused_files}) {
+ my $annex_dir = $self->git_path("annex");
my $last_unused = (stat(catfile($annex_dir, "unused")))[9];
my %branch_timestamps
= map { split ' ' }
@@ -231,6 +231,7 @@ sub unused_files {
# if we're still in the method at this point then the cache was
# invalidated; regenerate it
my ($bad, $tmp) = (0, 0);
+ %{ $self->{_unused_files}->{unused_args} } = %$unused_args;
foreach ($self->git->annex("unused", $unused_args)) {
if (/Some corrupted files have been preserved by fsck, just in case/) {
($bad, $tmp) = (1, 0);
@@ -242,8 +243,7 @@ sub unused_files {
}
}
$self->{_unused_files}->{timestamp} = time();
- $self->{_unused_files}->{unused_args} = $unused_args;
- store($self->{_unused_files}, $cache_file);
+ $self->_store_unused();
return $self->{_unused_files}->{unused};
}
@@ -251,6 +251,7 @@ sub log_unused {
my $self = shift;
foreach my $unused_file (@{ $self->{_unused_files}->{unused} }) {
+ next if defined $unused_file->{log_lines};
# We need the RUN here to avoid special postprocessing but
# also to get the -c option passed -- unclear how to pass
# short options to git itself, not the 'log' subcommand,
@@ -268,6 +269,17 @@ sub log_unused {
"-S",
$unused_file->{key});
}
+ $self->_store_unused();
+}
+
+sub _store_unused {
+ my $self = shift;
+ store($self->{_unused_files}, $self->_unused_cache_file);
+}
+
+sub _unused_cache_file {
+ my $annex_dir = shift->git_path("annex");
+ return catfile($annex_dir, "unused_info");
}
sub abs_contentlocation {