Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for scripts/perl/filesystem/hardlink-files.pl between version 1.5 and 1.6

version 1.5, 2005/07/10 22:17:13 version 1.6, 2005/07/24 21:40:48
Line 20 
Line 20 
 #  #
 #  #
   
 # $Platon: scripts/perl/filesystem/hardlink-files.pl,v 1.4 2005/05/24 15:43:00 rajo Exp $  # $Platon: scripts/perl/filesystem/hardlink-files.pl,v 1.5 2005/07/10 22:17:13 rajo Exp $
   
 use strict;  use strict;
   
Line 30  use Cwd qw( abs_path );
Line 30  use Cwd qw( abs_path );
 use File::Basename qw( basename fileparse );  use File::Basename qw( basename fileparse );
 use Digest::MD5;  use Digest::MD5;
 #use Digest::SHA1;  #use Digest::SHA1;
 use Data::Dumper;  #use Data::Dumper;
   use XML::Dumper;
 use Time::HiRes qw(gettimeofday tv_interval);  use Time::HiRes qw(gettimeofday tv_interval);
   
 $| = 1;  $| = 1;
Line 41  use vars qw (
Line 42  use vars qw (
         *file *dir *prune          *file *dir *prune
         $md5sums $cache $stat $stat_global $mountpoints          $md5sums $cache $stat $stat_global $mountpoints
         @directories          @directories
           $dump
 );  );
   
 unless (scalar(@ARGV)) {  unless (scalar(@ARGV)) {
Line 48  unless (scalar(@ARGV)) {
Line 50  unless (scalar(@ARGV)) {
         exit 1;          exit 1;
 }  }
   
 $cache_file = ".hardlink-cache";  $dump = new XML::Dumper;
   
   $cache_file = ".hardlink-cache.xml";
 $start = [gettimeofday];  $start = [gettimeofday];
   
 *file   = *File::Find::name;  *file   = *File::Find::name;
Line 144  foreach my $xdir (@directories) { # {{{
Line 148  foreach my $xdir (@directories) { # {{{
         my $file = "$xdir/$cache_file";          my $file = "$xdir/$cache_file";
         if (-f $file) {          if (-f $file) {
                 print "Trying to load cache file '$file' ... ";                  print "Trying to load cache file '$file' ... ";
                 my $code;                  my $hardlink_cache = $dump->xml2pl($file);
                 if (open(FILE, $file)) {                  if (defined $hardlink_cache and ref($hardlink_cache) eq 'HASH') {
                         while(<FILE>) {                          $cache->{$xdir} = $hardlink_cache;
                                 $code .= $_;                          print "OK\n"
                         }  
                         close(FILE);  
                         my $hardlink_cache = undef;  
                         eval $code;  
                         if ($@) {  
                                 print "failed: $@; ... removing\n";  
                                 unlink $file;  
                         }  
                         if (defined $hardlink_cache and ref($hardlink_cache) eq 'HASH') {  
                                 $cache->{$xdir} = $hardlink_cache;  
                                 print "OK\n"  
                         }  
                         else {  
                                 print "failed: bad structure; ... removing\n";  
                                 unlink $file;  
                         }  
                 }  
                 else {  
                         print STDERR "Can't open cache file '$file': $!";  
                 }                  }
         }          }
 } # }}}  } # }}}
Line 208  foreach my $xdir (@directories) { # {{{
Line 193  foreach my $xdir (@directories) { # {{{
         print "Saving cache file '$file' ... ";          print "Saving cache file '$file' ... ";
         if (open(FILE, ">$file")) {          if (open(FILE, ">$file")) {
                 #print Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);                  #print Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);
                 print FILE Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);                  # OLD INSECURE FORMAT OF CACHE
                   #print FILE Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);
                   # more safer new format:
                   print FILE $dump->pl2xml($cache->{$xdir});
                 close(FILE);                  close(FILE);
                 print "OK\n";                  print "OK\n";
         }          }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top