From 1af7a6a76a0cbfda953828b9bd5c0834553e6b24 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Apr 2017 13:39:47 +0200 Subject: Move backup path mapping to main package Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index d072a31..d5bb56b 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -120,6 +120,22 @@ sub resolve_relative_path { return $abs_path; } +sub map_path_to_backup_path { + my $self = shift; + my $abs_path = shift; + + my $backup_path = $abs_path; + + for my $backup_prefix (@App::BorgRestore::Settings::backup_prefixes) { + if ($backup_path =~ m/$backup_prefix->{regex}/) { + $backup_path =~ s/$backup_prefix->{regex}/$backup_prefix->{replacement}/; + last; + } + } + + return $backup_path; +} + sub find_archives { my $self = shift; my $path = shift; -- cgit v1.2.3-24-g4f1b