BackupPC-users

[BackupPC-users] Suggested improvements to MakeFileLink routine in Lib.pm

2011-01-23 01:11:44
Subject: [BackupPC-users] Suggested improvements to MakeFileLink routine in Lib.pm
From: "Jeffrey J. Kosowsky" <backuppc AT kosowsky DOT org>
To: General list for user discussion <backuppc-users AT lists.sourceforge DOT net>
Date: Sun, 23 Jan 2011 01:09:10 -0500
It seems there are some extra tests and computation that are not
necessary. I will show my suggested changes with +/- style diff
Am I missing something?


 sub MakeFileLink
 {
     my($bpc, $name, $d, $newFile, $compress) = @_;
     my($i, $rawFile);
 
     return -1 if ( !-f $name );
+        return -2 if ( !defined($rawFile = $bpc->MD52Path($d, $compress)) );
     for ( $i = -1 ; ; $i++ ) {
-        return -2 if ( !defined($rawFile = $bpc->MD52Path($d, $compress)) );
         $rawFile .= "_$i" if ( $i >= 0 );
         if ( -f $rawFile ) {
             if ( (stat(_))[3] < $bpc->{Conf}{HardLinkMax}
                     && !compare($name, $rawFile) ) {
                 unlink($name);
                 return -3 if ( !link($rawFile, $name) );
                 return 1;
             }
-         } elsif ( $newFile && -f $name && (stat($name))[3] == 1 ) {
+         } elsif ( $newFile && -f $name && (stat($_))[3] == 1 ) {
-             my($newDir);
-             ($newDir = $rawFile) =~ s{(.*)/.*}{$1};
+                        $rawfile =~ m{(.*)/}
-             mkpath($newDir, 0, 0777) if ( !-d $newDir );
+             mkpath($1, 0, 0777) if ( !-d $1 );
             return -4 if ( !link($name, $rawFile) );
             return 2;
         } else {
             return 0;
         }
     }
 }

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

<Prev in Thread] Current Thread [Next in Thread>