Forráskód Böngészése

So close I can feel it

Andy Baugh 5 éve
szülő
commit
ec566af37e
2 módosított fájl, 20 hozzáadás és 5 törlés
  1. 9 3
      js/pgupgrade.js
  2. 11 2
      lib/Troglodyne/API/Postgres.pm

+ 9 - 3
js/pgupgrade.js

@@ -152,7 +152,7 @@ function roadRoller (resp) {
 
         // Paste in new content
         upgradeWell.textContent += obj.data['new_content'];
-        if(obj.data.in_progress) {
+        if(obj.data['in_progress']) {
             // Not done yet, keep going
             doAPIRequestWithCallback(
                 'GET', 'Postgres', 'get_latest_upgradelog_messages', roadRoller, generalErrorHandler, {
@@ -163,10 +163,16 @@ function roadRoller (resp) {
             );
         } else {
             // Do something based on the end status
-
+            if(obj.data['child_exit']) {
+                upgradeWell.textContent += `Installation of PostgreSQL ${window.selectedVersion} failed: ${obj.data['child_exit']}`;
+                 submitBtn.textContent = 'Re-Try';
+                 submitBtn.disabled = false;
+                 return;
+            }
+            upgradeWell.textContent += `Installation of PostgreSQL ${window.selectedVersion} completed successfully!`;
         }
     } else {
-         upgradeWell.textContent += `Installlation PostgreSQL ${window.selectedVersion} failed: ${obj.error}`;
+         upgradeWell.textContent += `Installation of PostgreSQL ${window.selectedVersion} failed: ${obj.error}`;
          submitBtn.textContent = 'Re-Try';
          submitBtn.disabled = false;
     }

+ 11 - 2
lib/Troglodyne/API/Postgres.pm

@@ -105,13 +105,22 @@ sub start_postgres_install {
 # Elegance??? Websocket??? Nah. EZ mode actibated
 sub get_latest_upgradelog_messages {
     my ( $args_hr ) = @_;
-    my ( $line_no, $content, $child_exit );
+    my $child_exit;
     my $in_progress = -f "$dir/INSTALL_IN_PROGRESS";
     if(!$in_progress) {
         $child_exit = readlink("$dir/INSTALL_EXIT_CODE");
     }
 
-    # TODO: Actually read from it
+    # XXX validate log arg? Don't want arbitrary file reads?
+    # read from it using seek and tell to control
+    open( my $rh, "<", $args_hr->{'log'} );
+    seek( $rh, $args_hr->{'start'}, 0 ) if $args_hr->{'start'};
+    my $content = '';
+    while( my $line = <$rh> ) {
+        $content .= $line;
+    }
+    my $line_no = tell($rh);
+    close($rh);
 
     return {
         'in_progress' => $in_progress,