Skip to content

JaSei/File-Copy-Recursive-Verify

Repository files navigation

Build Status

NAME

File::Copy::Recursive::Verify - data-safe recursive copy

SYNOPSIS

use File::Copy::Recursive::Verify qw(verify_rcopy);

verify_rcopy($dir_a, $dir_b);

#OOP equivalent

File::Copy::Recursive::Verify->new(
    src_dir => $dir_a,
    dst_dir => $dir_b,
)->copy();

#some complex copy - I know SHA-256 hash of subdir/a.dat file
#tree $dir_a:
#.
#├── c.dat
#└── subdir
#    ├── a.dat
#    └── b.dat

verify_rcopy($dir_a, $dir_b, {tries => 3, hash_algo => 'SHA-256', src_hash => {'subdir/a.dat' => '0'x64}});

#OOP equivalent

File::Copy::Recursive::Verify->new(
    src_dir => $dir_a,
    dst_dir => $dir_b,
    tries   => 3,
    hash_algo => 'SHA-256',
    src_hash => {'subdir/a.dat' => 0x64},
)->copy();

DESCRIPTION

Use File::Copy::Verify for recursive copy.

FUNCTIONS

verify_rcopy($src_dir, $dst_dir, $options)

functional api

Recusive copy of dir_a to dir_b.

Retry mechanism is via Try::Tiny::Retry (Each file will try verify_copy 10 times with exponential backoff in default).

As verification digest are use fastest MD5 in default.

$options is HashRef of attributes.

return HashRef of copied files (key source, value destination)

rcopy

alias of verify_rcopy

METHODS

new(%attributes)

%attributes

src_dir

source dir

src_hash

source HashRef of path -> hash

dst_dir

destination dir

dst_hash

destination HashRef of path -> hash

hash_algo

hash algorithm

default MD5

tries

number of tries

more about retry - Try::Tiny::Retry

copy;

start recursive copy

return HashRef of copied files (key source, value destination)

LICENSE

Copyright (C) Avast Software.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Jan Seidl seidl@avast.com