Ignore:
Timestamp:
Apr 20, 2014, 11:24:46 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Change interface of mr_file_read_all_link to returning a hash of hash.
  • When recursing with a hash used, declare it with our so it's available correctly at all levels.
  • mr_file_read_all_link now really returns all the links neeed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/MondoRescue/lib/MondoRescue/File.pm

    r3229 r3262  
    8989This function returns all the links found for a given file passed as parameter
    9090Example: mr_file_read_all_link(/lib64) returns (/lib64,/usr/lib64) on a system having a link from /lib64 to /usr/lib64
    91 The return value is a hash of all input files pointing to arrays of links
     91The return value is a hash of all input files pointing to hash of links
    9292
    9393=cut
     
    9696
    9797# TODO: Can be parallelized
    98 my $files;
     98our $files;
    9999
    100100foreach my $f (@_) {
     
    114114            $link = mr_file_normalize($link,"$curdir/$dir");
    115115            # It's a real symlink so handle it
    116             push @{$files->{$f}},"$curdir/$dir";
     116            $files->{$f}->{"$curdir/$dir"} = 1;
    117117            if (substr($link,0,1) eq "/") {
    118118                $curdir = $link;
     
    124124            if ((-e $curdir) && ((! -d $curdir) || (-l $curdir))) {
    125125                my $h = mr_file_read_all_link($curdir);
    126                 pb_log(2,"File: $curdir - Return:\n".Dumper($h)."\n");
     126                pb_log(2,"After Return h:\n".Dumper($h)."\n");
    127127                foreach my $k (keys %$h) {
    128                     # At that point there is only one key
    129                     # as there was one param passed to the function.
    130128                    foreach my $l (keys %$k) {
    131                         push @{$files->{$f}},$k->{$l};
     129                        # Use $f as key as we affects all the files
     130                        # found in recursion to the current managed file
     131                        $files->{$f}->{$l} = 1;
    132132                    }
    133133                }
     134                pb_log(2,"After Return files:\n".Dumper($files)."\n");
    134135            }
    135136        } else {
     
    138139    }
    139140    pb_log(2,"curdir is now: $curdir**\n");
    140     push @{$files->{$f}},$curdir if (-e $curdir);
    141 }
     141    $files->{$f}->{$curdir} = 1 if (-e $curdir);
     142}
     143pb_log(1,"mr_file_read_all_link returns:\n".Dumper($files)."\n");
    142144return($files);
    143145}
Note: See TracChangeset for help on using the changeset viewer.