Updated Storage->read_file() to test if the target file exists.

This allows for better logging if the file to be copied doesn't exist.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent ab6acd594c
commit 85f86cda8a
  1. 27
      Anvil/Tools/Storage.pm
  2. 1
      share/words.xml

@ -4178,6 +4178,33 @@ sub read_file
return("!!error!!"); return("!!error!!");
} }
### TODO: The '$file' should be bash-escaped.
# See if the file even exists on the target.
my $shell_call = $anvil->data->{path}{exe}{ls}." '".$file."'";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => $debug,
target => $target,
port => $port,
password => $password,
remote_user => $remote_user,
shell_call => $shell_call,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
error => $error,
output => $output,
return_code => $return_code,
}});
if ($return_code)
{
# The file doesn't exist, so we can't copy it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0465", variables => {
file => $file,
target => $target,
}});
return("!!error!!");
}
# Setup the temp file name. # Setup the temp file name.
my $temp_file = $file; my $temp_file = $file;
$temp_file =~ s/\//_/g; $temp_file =~ s/\//_/g;

@ -733,6 +733,7 @@ The XML that failed sanity check was:
#!variable!xml!# #!variable!xml!#
======== ========
]]></key> ]]></key>
<key name="error_0465"><![CDATA[The file: [#!variable!file!#] doesn't exist on the target: [#!variable!target!#].]]></key>
<!-- Files templates --> <!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable --> <!-- NOTE: Translating these files requires an understanding of which lines are translatable -->

Loading…
Cancel
Save