Fixed a bug in Remote->call()

* If the call to Remote-call() set the target that was actually the
  local short hostname, it would fail to make the call at all. Now if
  the 'target' is local, the shell call is instead passed to
  System->call() instead.
* Cleaned up logging.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 07cedb601f
commit fd461f940d
  1. 12
      Anvil/Tools/Database.pm
  2. 16
      Anvil/Tools/Remote.pm
  3. 5
      tools/anvil-manage-files

@ -19699,7 +19699,7 @@ ORDER BY
my $variable_source_uuid = $row->[4] ? $row->[4] : "none"; my $variable_source_uuid = $row->[4] ? $row->[4] : "none";
my $variable_value = $row->[5]; my $variable_value = $row->[5];
my $modified_date = $row->[6]; my $modified_date = $row->[6];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
variable_uuid => $variable_uuid, variable_uuid => $variable_uuid,
variable_section => $variable_section, variable_section => $variable_section,
variable_name => $variable_name, variable_name => $variable_name,
@ -19712,12 +19712,12 @@ ORDER BY
if (not $variable_source_table) if (not $variable_source_table)
{ {
$variable_source_table = "none"; $variable_source_table = "none";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { variable_source_table => $variable_source_table }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_source_table => $variable_source_table }});
} }
if (not $variable_source_uuid) if (not $variable_source_uuid)
{ {
$variable_source_uuid = "none"; $variable_source_uuid = "none";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { variable_source_uuid => $variable_source_uuid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_source_uuid => $variable_source_uuid }});
} }
if ((not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) && if ((not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) &&
@ -19726,7 +19726,7 @@ ORDER BY
# Save it. # Save it.
$anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value;
$anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid; $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value}, "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value},
"duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid}, "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid},
}}); }});
@ -19734,7 +19734,7 @@ ORDER BY
else else
{ {
# Duplicate! This is older, so delete it. # Duplicate! This is older, so delete it.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value}, "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value},
"duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid}, "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid},
}}); }});
@ -19752,7 +19752,7 @@ ORDER BY
push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";";
foreach my $query (@{$queries}) foreach my $query (@{$queries})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
} }
$anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__}); $anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__});
} }

@ -222,6 +222,8 @@ Any output from the call will be stored in C<< $output >>. STDERR and STDOUT are
B<NOTE>: By default, a connection to a target will be held open and cached to increase performance for future connections. B<NOTE>: By default, a connection to a target will be held open and cached to increase performance for future connections.
B<NOTE>: If the C<< target >> is actually the local system, C<< System->call >> is called instead, and the C<< error >> variable will be set to C<< local >>.
Parameters; Parameters;
=head3 close (optional, default '0') =head3 close (optional, default '0')
@ -337,11 +339,17 @@ sub call
}}); }});
} }
# In case 'target' is our short host name, change it to ''. # If the call is to ourselves, switch to a local system call.
if ($target eq $anvil->Get->short_host_name()) if ($anvil->Network->is_local({host => $target}))
{ {
$target = ""; # Use a local system call.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { target => $target }}); my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output,
return_code => $return_code,
}});
return($output, "local", $return_code);
} }
if (not $shell_call) if (not $shell_call)

@ -54,11 +54,6 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
$anvil->Get->switches({list => ["add", "check", "delete", "download", "file", "is-script", "rename", "remove", "to"], man => $THIS_FILE}); $anvil->Get->switches({list => ["add", "check", "delete", "download", "file", "is-script", "rename", "remove", "to"], man => $THIS_FILE});
### TODO: Remove this
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
# Connect or die # Connect or die

Loading…
Cancel
Save