App-BorgRestore

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN

    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an

lib/App/BorgRestore/PathTimeTable/DB.pm  view on Meta::CPAN

App::BorgRestore::PathTimeTable::DB - Directly write new archive data to the database

=head1 DESCRIPTION

This is used by L<App::BorgRestore> to add new archive data into the database.
Data is written to the database directly and existing data is updated where necessary.

For performance reasons this class keeps an internal cache so that the database
is only contacted when necessary. The cache assumes that the path are sorted so
that all files from one directory are added, before files from another. If a
path from a different directory is added, the previous cache is invalidated.
Upon invalidation the time stamp is written to the database. If paths are
properly sorted, this results in only a single database write for each path.

=cut


method new($class: $deps = {}) {
	return $class->new_no_defaults($deps);
}

lib/App/BorgRestore/PathTimeTable/DB.pm  view on Meta::CPAN

}

method set_archive_id($archive_id) {
	$self->{archive_id} = $archive_id;
}

method add_path($path, $time) {
	$log->tracef("Adding path to cache: %s", $path) if TRACE;
	$self->{stats}->{total_paths}++;
	my $old_cache_path = $self->{current_path_in_cache};
	# Check if the new path requires us to (partially) invalidate our cache and
	# add any files/directories to the database. If the new path is a subpath
	# (substring actually) of the cached path, we can keep it only in the cache
	# and no flush is needed. Otherwise we need to flush all parts of the path
	# that are no longer contained in the new path.
	#
	# We start by checking the currently cached path ($old_cache_path) against
	# the new $path. Then we remove one part from the path at a time, until we
	# reach a parent path (directory) of $path.
	$log->tracef("Checking if cache invalidation is required") if TRACE;
	while ((my $slash_index = rindex($old_cache_path, "/")) != -1) {



( run in 0.490 second using v1.01-cache-2.11-cpan-a5abf4f5562 )