From 3821d907dd555545d26608444612804a6bab2aca Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 18 Oct 2016 18:28:15 +0100 Subject: more injection --- lib/AniDB/Manager.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/AniDB/Manager.pm b/lib/AniDB/Manager.pm index 0539c07..078946c 100644 --- a/lib/AniDB/Manager.pm +++ b/lib/AniDB/Manager.pm @@ -4,7 +4,6 @@ use experimental 'signatures'; use Moo; use Log::Any '$log'; use Path::Tiny; -use AniDB::Hashing; use namespace::clean; has datastore => ( @@ -44,6 +43,16 @@ sub _build_renamer { return AniDB::Renamer->new(); } +has hash_function => ( + is => 'ro', + lazy => 1, +); + +sub _build_hash_function { + require AniDB::Hashing; + return \&AniDB::Hashing::hash_fd; +} + sub new_name_for($self,$path) { $path = path($path)->realpath; $self->update($path); @@ -80,7 +89,7 @@ sub update($self,$path) { return unless $self->datastore->has_changed($path,$stat); - my $hash = AniDB::Hashing::hash_fd($path->openr_raw); + my $hash = $self->hash_function->($path->openr_raw); $self->datastore->update_path_info( $path => my $path_info = { -- cgit v1.2.3