-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

JT Moree wrote:
> Is the multiple path feature as discussed in this thread planned to be
> implemented in dirvish?  

I have hacked dirvish to work use the paths variable as an array.
Unlike the previous patch this should work with remote clients.  I use
arrays for paths, srctree, destree, reftree, and run rsync multiple times.

One HUGE problem is:  What's with the runloops?  It runs the main block
of code 4 times?  why.  Since I now have n paths this will mean n*4 runs
of rsync.  I need to understand why this is here so I can deal with it.

  for ($runloops = 0; $runloops < 5; ++$runloops)

It's not finished yet but you can see where I am going with the attached
patch.

Thank you

- --
JT Moree
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGFYXeFI6sVJUR1B8RAhZDAJwI41kocYFe0ElcPY1f5AcDOmXdYQCgrjcf
VE4fyyS0oqNN1EUeFGXOL3Q=
=qit2
-----END PGP SIGNATURE-----
diff -u dirvish-1.2.1/dirvish.pl dirvish-1.2.1-paths/dirvish.pl
--- dirvish-1.2.1/dirvish.pl    2005-02-18 18:07:53.000000000 -0700
+++ dirvish-1.2.1-paths/dirvish.pl      2007-04-05 16:04:25.000000000 -0700
@@ -228,6 +228,7 @@
        vault=s
        client=s
        tree=s
+  path=s@
        image=s
        image-time=s
        expire=s
@@ -423,6 +424,17 @@
 
 $destree = join("/", $vault, $image, 'tree');
 $reftree = join('/', $vault, $$Options{Reference}, 'tree');
+#build pathtrees here
+my @srctree;
+my @destree;
+my @reftree;
+my @paths = @{$Options{paths}};
+foreach my $p (@paths)
+{
+       push(@destree, "$destree/$p");
+       push(@srctree, "$srctree/$p");
+       push(@reftree, "$reftree/$p");
+}
 $err_temp = join("/", $vault, $image, 'rsync_error.tmp');
 $err_file = join("/", $vault, $image, 'rsync_error');
 $log_file = join("/", $vault, $image, 'log');
@@ -453,7 +465,17 @@
 {
        mkdir "$vault/$image", 0700
                or seppuku 230, "mkdir $vault/$image failed";
-       mkdir $destree, 0755;
+       if (@destree)
+       {
+               foreach my $p (@destree)
+               {
+                       mkdir $p, 0755;
+               }
+       }
+       else
+       {
+               mkdir $destree, 0755;
+       }
 
        open(SUMMARY, ">$vault/$image/summary")
                or seppuku 231, "cannot create $vault/$image/summary"; 
@@ -509,8 +531,6 @@
        printf SUMMARY "%s: %s\n", $key, $val;
 }
 
-$$Options{init} or push @rsyncargs, "--link-dest=$reftree";
-
 $rclient = undef;
 $$Options{client} ne $$Options{Server}
        and $rclient = $$Options{client} . ':';
@@ -520,11 +540,27 @@
 @cmd = (
        ($$Options{rsync} ? $$Options{rsync} : 'rsync'),
        @rsyncargs,
+       "--link-dest=$reftree",
        $rclient . $srctree . '/',
        $destree
        );
 printf SUMMARY "\n%s: %s\n", 'ACTION', join (' ', @cmd);
 
+#the above @cmd will be ignored if @paths are set so it can run unmodified
+#allow for multiple paths and run rsync multiple times
+for (my $i = 0; $i < scalar @paths; $i++)
+{
+       my @cmd_t = (
+               ($$Options{rsync} ? $$Options{rsync} : 'rsync'),
+               @rsyncargs,
+               "--link-dest=$reftree[$i]",
+               $rclient . $srctree[$i] . '/',
+               $destree[$i]
+               );
+       printf SUMMARY "\n%s: %s\n", 'ACTION', join (' ', @cmd_t);
+       $cmd{$paths[$i]} = @cmd_t;
+}
+
 $$Options{'no-run'} and exit 0;
 
 printf SUMMARY "%s: %s\n", 'Backup-begin', strftime('%Y-%m-%d %H:%M:%S', 
localtime);
@@ -615,6 +651,7 @@
 print FSBUF "         \n" x 6553;
 close FSBUF;
 
+#!!!i dont understand this runloops stuff.  why is it here.  If I wrap the 
calls to system(@cmd) then they are going to be run more than once.  4 times 
actually
 for ($runloops = 0; $runloops < 5; ++$runloops)
 {
        logappend($log_file, sprintf("\n%s: %s\n", 'ACTION', join(' ', @cmd)));
@@ -631,7 +668,17 @@
        open (OUTHOLD, ">&STDOUT");
        open (STDOUT, ">$log_temp");
 
-       $status{code} = (system(@cmd) >> 8) & 255;
+  if (@paths)
+  {
+               foreach my $p (keys %cmd)
+               {
+                       $status{code} = (system($cmd{$p}) >> 8) & 255;
+               }
+       }
+       else
+       {
+               $status{code} = (system(@cmd) >> 8) & 255;
+       }
 
        open (STDERR, ">&ERRHOLD");
        open (STDOUT, ">&OUTHOLD");
_______________________________________________
Dirvish mailing list
[email protected]
http://www.dirvish.org/mailman/listinfo/dirvish

Reply via email to