summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore/PathTimeTable
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-09-12 23:02:19 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-09-12 23:07:47 +0200
commit02f5bf83435fd26850a8c093783f6240a76a5fda (patch)
tree825ff5506236b645e8dc71c6193b1eb4e60ce125 /lib/App/BorgRestore/PathTimeTable
parentb42d7f36f95c069946a82793f8fd8b8cda650127 (diff)
downloadApp-BorgRestore-02f5bf83435fd26850a8c093783f6240a76a5fda.tar.gz
App-BorgRestore-02f5bf83435fd26850a8c093783f6240a76a5fda.tar.xz
Update cache only when going back up the stack instead of all the time
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/BorgRestore/PathTimeTable')
-rw-r--r--lib/App/BorgRestore/PathTimeTable/DB.pm22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/App/BorgRestore/PathTimeTable/DB.pm b/lib/App/BorgRestore/PathTimeTable/DB.pm
index 3242b76..73dbc5b 100644
--- a/lib/App/BorgRestore/PathTimeTable/DB.pm
+++ b/lib/App/BorgRestore/PathTimeTable/DB.pm
@@ -57,16 +57,13 @@ method add_path($path, $time) {
$self->_add_path_to_db($self->{archive_id}, $old_cache_path, $removed_time);
# strip last part of path
$old_cache_path = substr($old_cache_path, 0, $slash_index);
- }
- my $full_path = $path;
- while ((my $slash_index = rindex($path, "/")) != -1) {
- my $cached = $self->{cache}->{$path};
- if (!defined $cached || $cached < $time) {
- $log->tracef("Setting cache time for path '%s' to %d", $path, $time) if TRACE;
- $self->{cache}->{$path} = $time;
+ # update parent timestamp
+ my $cached = $self->{cache}->{$old_cache_path};
+ if (!defined $cached || $cached < $removed_time) {
+ $log->tracef("Setting cache time for path '%s' to %d", $old_cache_path, $removed_time) if TRACE;
+ $self->{cache}->{$old_cache_path} = $removed_time;
}
- $path = substr($path, 0, $slash_index);
}
if ($old_cache_path ne substr($path, 0, length($old_cache_path))) {
@@ -79,7 +76,7 @@ method add_path($path, $time) {
$log->tracef("Setting cache time for path '%s' to %d", $path, $time) if TRACE;
$self->{cache}->{$path} = $time;
}
- $self->{current_path_in_cache} = $full_path;
+ $self->{current_path_in_cache} = $path;
}
method _add_path_to_db($archive_id, $path,$time) {
@@ -100,6 +97,13 @@ method save_nodes() {
$self->_add_path_to_db($self->{archive_id}, $old_cache_path, $removed_time);
# strip last part of path
$old_cache_path = substr($old_cache_path, 0, $slash_index);
+
+ # update parent timestamp
+ my $cached = $self->{cache}->{$old_cache_path};
+ if (!defined $cached || $cached < $removed_time) {
+ $log->tracef("Setting cache time for path '%s' to %d", $old_cache_path, $removed_time) if TRACE;
+ $self->{cache}->{$old_cache_path} = $removed_time;
+ }
}
# ensure that top level directory is also written
$self->_add_path_to_db($self->{archive_id}, $old_cache_path, $self->{cache}->{$old_cache_path});