[Bps-public-commit] r14717 - in Pushmi/trunk: . Pushmi-Admin/lib/Pushmi/Admin/Action Pushmi-Admin/lib/Pushmi/Admin/Model

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Aug 1 14:59:20 EDT 2008


Author: alexmv
Date: Fri Aug  1 14:59:15 2008
New Revision: 14717

Modified:
   Pushmi/trunk/   (props changed)
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm

Log:
 r35177 at kohr-ah:  chmrr | 2008-08-01 14:59:05 -0400
  * Bootstrap support; needs latest SVK


Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/Sync.pm	Fri Aug  1 14:59:15 2008
@@ -14,8 +14,8 @@
 use Jifty::Action schema {
 
     param bootstrap =>
-        type is 'file',
-        label is "Bootstrap file";
+        type is 'text',
+        label is "Bootstrap file", ajax validates;
 
     param replica =>
         type is 'integer',
@@ -23,12 +23,29 @@
 
 };
 
+use LWP::UserAgent;
+
+sub validate_bootstrap {
+    my $self = shift;
+    my ($url) = shift;
+   
+    return $self->validation_error( bootstrap => "That doesn't look like a URL" )
+      unless $url =~ m{^(file|https?|ftp)://};
+    my $ua = LWP::UserAgent->new(agent => "Pushmi");
+    my $response = $ua->head($url);
+    return $self->validation_error( bootstrap => $response->status_line)
+      unless $response->is_success;
+    return $self->validation_ok( "bootstrap" );
+}
+
 sub take_action {
     my $self = shift;
 
     my $replica = Pushmi::Admin::Model::Replica->load(
         $self->argument_value("replica") );
-    $replica->sync;
+
+    $replica->sync($self->argument_value("bootstrap"));
+
     if ( $replica->status eq "behind" ) {
         $self->result->message("Synchronization started");
     }

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Dispatcher.pm	Fri Aug  1 14:59:15 2008
@@ -16,7 +16,7 @@
     }
 };
 
-on qr{^/replica/(.*?)-\d{4}-\d{2}-\d{2}\.gz$} => run {
+on qr{^/replica/(.*?)(-\d{4}-\d{2}-\d{2})?\.gz$} => run {
     my $replica = Pushmi::Admin::Model::Replica->new;
     $replica->load_by_cols( clean_name => $1 );
     show '/errors/404' unless $replica->id;

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm	Fri Aug  1 14:59:15 2008
@@ -119,12 +119,15 @@
 sub sync {
     my $self = shift;
     return if $self->pushmi and $self->pushmi->locked;
+    my ($bootstrap) = @_;
 
     unless (fork) {
         close STDOUT;
         close STDIN;
-        exec( $^X, Jifty->config->app("pushmi_bin"), "sync",
-            $self->svn_root );
+        my @args = ($^X, Jifty->config->app("pushmi_bin"), "sync", $self->svn_root);
+        push @args, "--bootstrap", $bootstrap if $bootstrap;
+
+        exec(@args);
     }
     $self->clear_cache;
 }

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	Fri Aug  1 14:59:15 2008
@@ -132,13 +132,20 @@
                 . " revisions from the remote mirror.  This may take some time!";
         };
 
-#        p {
-#            "If you have a bootstrap file for this mirror, you can upload it below."
-#        };
         form {
             my $sync = Jifty->web->new_action( class => "Sync", );
             render_param(
                 $sync => "replica" => default_value => $replica->id );
+
+            p {
+                "If you have a bootstrap file for this mirror, you can
+                provide a URL to it below, which will significantly
+                speed up the process.";
+            };
+
+            render_param(
+                $sync => "bootstrap" );
+            
             form_submit( label => "Start mirroring", onclick => {submit => $sync, region => "progress-".$replica->id, replace_with => "/fragments/progressbar", effect => "Appear"} );
         }
     } elsif ( $replica->status ne "failed" ) {



More information about the Bps-public-commit mailing list