summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-02-01 14:18:28 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-02-01 14:18:28 -0700
commitf48595c3d891765cf4d20cf5a9a829c3ab295cb5 (patch)
treeddb59bd8a320a284f85298d4f3e7924cb97dd45c
parent7c6d991939009024e233d345d3e165017ff17e41 (diff)
downloadp5-Git-Annex-f48595c3d891765cf4d20cf5a9a829c3ab295cb5.tar.gz
add _store_unused_cache too
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--lib/Git/Annex.pm6
-rwxr-xr-xt/11_utils.t7
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Git/Annex.pm b/lib/Git/Annex.pm
index 7d923f9..4287126 100644
--- a/lib/Git/Annex.pm
+++ b/lib/Git/Annex.pm
@@ -108,6 +108,12 @@ has _unused_cache => (
is => "lazy",
default => sub { shift->_git_path(catfile(qw(annex unused_info))) });
+sub _store_unused_cache {
+ my $self = shift;
+ $self->{_unused}{timestamp} = time;
+ store $self->{_unused}, $self->_unused_cache;
+}
+
sub _clear_unused_cache {
my $self = shift;
delete $self->{_unused};
diff --git a/t/11_utils.t b/t/11_utils.t
index 6602cb8..f982967 100755
--- a/t/11_utils.t
+++ b/t/11_utils.t
@@ -9,7 +9,8 @@ use Test::More;
use Git::Annex;
use File::Spec::Functions qw(catfile);
use t::Setup;
-use File::Slurp;
+use Storable;
+use Data::Compare;
with_temp_annexes {
my $temp = shift;
@@ -20,7 +21,9 @@ with_temp_annexes {
ok $annex->_unused_cache eq $unused_info,
"_unused_cache resolves to correct path";
$annex->{_unused} = { foo => "bar" };
- write_file $unused_info, "baz\n";
+ $annex->_store_unused_cache;
+ ok Compare($annex->{_unused}, retrieve $unused_info),
+ "_store_unused_cache stores the cache";
$annex->_clear_unused_cache;
ok !exists $annex->{_unused}, "_clear_unused_cache clears unused hashref";
ok !-f $unused_info, "_clear_unused_cache deletes the cache";