* Got more work done on file management. A file name is now clickable and that loads a menu to rename, change the file type, purge (delete from everywhere) and select which Anvil! systems the file belongs on. Got the code done to purge a file, but it's not tested yet.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent ea84ba68eb
commit 6da2b3b17b
  1. 44
      Anvil/Tools/Database.pm
  2. 141
      cgi-bin/striker
  3. 163
      html/skins/alteeve/files.html
  4. 33
      html/skins/alteeve/main.css
  5. 25
      share/words.xml
  6. 98
      tools/anvil-sync-shared

@ -2351,6 +2351,12 @@ FROM
"file_locations::file_location_uuid::${file_location_uuid}::file_location_active" => $anvil->data->{file_locations}{file_location_uuid}{$file_location_uuid}{file_location_active},
"file_locations::file_location_uuid::${file_location_uuid}::modified_date" => $anvil->data->{file_locations}{file_location_uuid}{$file_location_uuid}{modified_date},
}});
# Make it easy to find files by anvil and file UUID.
$anvil->data->{file_locations}{anvil_uuid}{$file_location_anvil_uuid}{file_uuid}{$file_location_file_uuid}{file_location_uuid} = $file_location_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"file_locations::anvil_uuid::${file_location_anvil_uuid}::file_uuid::${file_location_file_uuid}::file_location_uuid" => $anvil->data->{file_locations}{anvil_uuid}{$file_location_anvil_uuid}{file_uuid}{$file_location_file_uuid}{file_location_uuid},
}});
}
return(0);
@ -7265,6 +7271,8 @@ This updates (or inserts) a record in the 'jobs' table. The C<< job_uuid >> refe
If there is an error, an empty string is returned.
B<< Note >>: if the C<< job_host_uuid >> is set to C<< all >>, a hash reference will be returned where they keys are the C<< host_uuid >> and the value is the C<< job_uuid >>.
Parameters;
=head3 uuid (optional)
@ -7299,6 +7307,8 @@ Variables can not be passed to this title key.
This is the host's UUID that this job entry belongs to. If not passed, C<< sys::host_uuid >> will be used.
B<< Note >>: If this is set to C<< all >>, the job will be recorded once for each host in the C<< hosts >> table.
=head3 job_name (required*)
This is the C<< job_name >> to INSERT or UPDATE. If a C<< job_uuid >> is passed, then the C<< job_name >> can be changed.
@ -7447,6 +7457,40 @@ sub insert_or_update_jobs
return("");
}
# If the job_host_uuid is set to 'all', go into a loop and call ourselves once per host using their host_uuid.
if ($job_host_uuid eq "all")
{
my $job_uuids = {};
$anvil->Database->get_hosts({debug => $debug});
foreach my $host_uuid (keys %{$anvil->data->{hosts}{host_uuid}})
{
my $host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_uuid => $host_uuid,
host_name => $host_name,
}});
$host_name->{$host_uuid} = $anvil->Database->insert_or_update_jobs({
debug => $debug,
job_command => $job_command,
job_data => $job_data,
job_picked_up_by => $job_picked_up_by,
job_picked_up_at => $job_picked_up_at,
job_updated => $job_updated,
job_name => $job_name,
job_progress => $job_progress,
job_title => $job_title,
job_description => $job_description,
job_status => $job_status,
update_progress_only => $update_progress_only,
clear_status => $clear_status,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "host_name->{$host_uuid}" => $host_name->{$host_uuid} }});
}
return($job_uuids);
}
if (not $job_updated)
{
$job_updated = time;

@ -1436,28 +1436,59 @@ AND
return(0);
}
# This processes changes to files, including deletions (purges).
sub process_file_change
{
my ($anvil) = @_;
# First, clear the 'save' and 'confirm' buttons.
$anvil->data->{cgi}{save}{value} = "";
$anvil->data->{cgi}{confirm}{value} = "";
# Are we being asked to purge a file?
if ($anvil->data->{cgi}{purge}{value})
{
# Register jobs on all systems to remove this file.
$anvil->Database->insert_or_update_jobs({
debug => 2,
file => $THIS_FILE,
line => __LINE__,
job_host_uuid => "all",
job_command => $anvil->data->{path}{exe}{'anvil-sync-shared'},
job_data => "file_uuid=".$anvil->data->{cgi}{file_uuid}{value},
job_name => "storage::purge",
job_title => "job_0136",
job_description => "job_0137",
job_progress => 0,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node1_job_uuid => $node1_job_uuid }});
}
return(0);
}
# This handles files.
sub process_file_menu
{
my ($anvil) = @_;
$anvil->data->{form}{refresh_link} = "striker?files=true";
$anvil->data->{form}{refresh_link} = "?files=true";
#$anvil->data->{form}{back_link} = "?striker=true";
$anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value};
$anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
$anvil->data->{cgi}{file_uuid}{value} = "" if not defined $anvil->data->{cgi}{file_uuid}{value};
$anvil->data->{cgi}{save}{value} = "" if not defined $anvil->data->{cgi}{save}{value};
$anvil->data->{cgi}{confirm}{value} = "" if not defined $anvil->data->{cgi}{confurm}{value};
if ($anvil->data->{cgi}{file_uuid}{value})
if (($anvil->data->{cgi}{file_uuid}{value}) && ($anvil->data->{cgi}{save}{value}) && ($anvil->data->{cgi}{confirm}{value}))
{
#process_upload_page($anvil);
process_file_change($anvil);
}
else
{
### TODO: Left off here. Show the available files and make them clickable. On click, make it
### possible to select which Anvil! systems should have the files, and offer an option
### to "purge" the file from all systems.
# Build the list of existing files.
$anvil->Database->get_files({debug => 2});
$anvil->Database->get_files();
my $file_list = $anvil->Template->get({file => "files.html", name => "open-file-list"});
foreach my $file_name (sort {$a cmp $b} keys %{$anvil->data->{files}{file_name}})
{
@ -1480,6 +1511,97 @@ sub process_file_menu
file_size => $say_file_size,
md5sum => $file_md5sum,
}});
if ($anvil->data->{cgi}{file_uuid}{value} eq $file_uuid)
{
$anvil->data->{form}{refresh_link} = "?files=true&file_uuid=".$anvil->data->{cgi}{file_uuid}{value};
$anvil->data->{form}{back_link} = "?files=true";
$anvil->data->{cgi}{new_file_name}{value} = "" if not defined $anvil->data->{cgi}{new_file_name}{value};
$anvil->data->{cgi}{new_file_name}{alert} = "" if not defined $anvil->data->{cgi}{new_file_name}{alert};
$anvil->data->{cgi}{new_file_type}{value} = $file_type if not defined $anvil->data->{cgi}{new_file_type}{value};
# Build the file type select
my $file_type_options = [
"iso#!#".$anvil->Words->string({key => "type_0001"}),
"script#!#".$anvil->Words->string({key => "type_0002"}),
"other#!#".$anvil->Words->string({key => "type_0003"})
];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::new_file_type::value" => $anvil->data->{cgi}{new_file_type}{value} }});
my $select_file_type = $anvil->Template->select_form({
name => "new_file_type",
options => $file_type_options,
blank => 0,
'sort' => 1,
selected => $anvil->data->{cgi}{new_file_type}{value},
class => "input_clear",
style => "",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { select_file_type => $select_file_type }});
# Build the anvil list
$anvil->Database->get_anvils();
$anvil->Database->get_file_locations();
my $say_confirm = "&nbsp;";
my $anvil_list = "";
if (not exists $anvil->data->{anvils}{anvil_name})
{
$anvil_list .= $anvil->Template->get({file => "files.html", name => "file-list-manager-no-anvils"});
}
else
{
foreach my $anvil_name (sort {$a cmp $b} keys %{$anvil->data->{anvils}{anvil_name}})
{
my $anvil_uuid = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_uuid};
my $anvil_description = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_description};
my $file_location_uuid = $anvil->data->{file_locations}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_location_uuid};
my $synced = $anvil->data->{file_locations}{file_location_uuid}{$file_location_uuid}{file_location_active};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:anvil_name" => $anvil_name,
"s2:anvil_uuid" => $anvil_uuid,
"s3:anvil_description" => $anvil_description,
"s4:file_location_uuid" => $file_location_uuid,
"s5:synced" => $synced,
}});
my $true_checked = "checked";
my $false_checked = "";
if (not $synced)
{
$true_checked = "";
$false_checked = "checked";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:true_checked" => $true_checked,
"s2:false_checked" => $false_checked,
}});
if (($anvil->data->{cgi}{save}{value}) && (not $anvil->data->{cgi}{confirm}{value}))
{
$say_confirm = $anvil->Template->get({file => "files.html", name => "file-list-manager-confirm-button"});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_confirm => $say_confirm }});
$anvil_list .= $anvil->Template->get({file => "files.html", name => "file-list-manager-anvil-entry", variables => {
anvil_name => $anvil_name,
anvil_description => $anvil_description,
radio_name => "anvil_uuid::".$anvil_uuid."::sync",
true_checked => $true_checked,
false_checked => $false_checked,
}});
}
}
# Insert the file management section under the file entry.
$file_list .= $anvil->Template->get({file => "files.html", name => "file-list-manager", variables => {
file_uuid => $file_uuid,
new_file_name => $anvil->data->{cgi}{new_file_name}{value},
new_file_type => $select_file_type,
confirm_button => $say_confirm,
new_file_name_class => $anvil->data->{cgi}{new_file_name}{alert} ? "input_alert_fixed" : "input_clear_fixed",
anvil_list => $anvil_list,
}});
}
}
$file_list .= $anvil->Template->get({file => "files.html", name => "close-file-list"});
@ -1489,7 +1611,6 @@ sub process_file_menu
$anvil->data->{form}{body} = $anvil->Template->get({file => "files.html", name => "main-menu", variables => {
file_list => $file_list,
}});
}
return(0);
}

@ -2,7 +2,6 @@
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="#!data!skin::url!#/files.js"></script>
<link rel="stylesheet" href="#!data!skin::url!#/files.css">
<form method="post" enctype="multipart/form-data">
<tr>
<td colspan="3" class="menu_title" style="text-align: center;" >
#!string!striker_0119!#
@ -29,7 +28,6 @@
&nbsp;
</td>
</tr>
</form>
</table>
<!-- end main-menu -->
@ -78,7 +76,7 @@
<!-- start file-list-entry -->
<tr>
<td class="fixed_width_no_wrap">
<a href="?files=true&file_uuid=#!variable!file_uuid!#"><img src="#!data!skin::url!#/images/manage_file_32.png" alt="#!string!message_0281!#" style="height: .8em;"></a>
<a href="?files=true&file_uuid=#!variable!file_uuid!#"><img src="#!data!skin::url!#/images/manage_file_32.png" alt="#!string!striker_0281!#" style="height: .8em;"></a>
</td>
<td>
&nbsp;
@ -107,6 +105,165 @@
</tr>
<!-- end file-list-entry -->
<!-- start file-list-manager -->
<tr>
<td colspan="9">
&nbsp;
</td>
</tr>
<tr>
<td colspan="9" style="text-align: center; white-space: nowrap;">
<form method="post" enctype="multipart/form-data">
<table class="manager">
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
<tr>
<td class="row_header">
<!-- New File Name -->
#!string!header_0047!#: &nbsp;
</td>
<td colspan="3">
<input type="text" id="new_file_name" name="new_file_name" placeholder="#!variable!file_name!#" value="#!variable!new_file_name!#" class="#!variable!new_file_name_class!#" />
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td class="row_header">
<!-- New File Type -->
#!string!header_0048!#: &nbsp;
</td>
<td colspan="3">
#!variable!new_file_type!#
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td class="row_header">
<!-- Purge option -->
<a href="?files=true&file_uuid=#!variable!file_uuid!#&purge=true"><span class="risky_click">#!string!header_0049!#</span></a> &nbsp;
</td>
<td colspan="3" style="text-align: left;">
#!string!striker_0282!#
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
<tr>
<td class="column_header" style="text-align: right;">
<!-- Anvil List -->
#!string!header_0050!# &nbsp;
</td>
<td>
&nbsp;
</td>
<td class="column_header" style="text-align: center;">
<!-- Synced -->
#!string!header_0051!#
</td>
<td class="column_header" style="text-align: center;">
<!-- Remove -->
#!string!header_0052!#
</td>
<td>
&nbsp;
</td>
</tr>
#!variable!anvil_list!#
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
<tr>
<td style="text-align: left;">
<!-- Back -->
&nbsp; <a href="?files=true" class="button">#!string!striker_0284!#</a>
</td>
<td>
&nbsp;
</td>
<td style="text-align: right;">
#!variable!confirm_button!#
</td>
<td style="text-align: right;">
<input type="submit" name="save" id="save" value="#!string!striker_0067!#" class="button">
<input type="hidden" name="files" id="files" value="true" />
<input type="hidden" name="file_uuid" id="file_uuid" value="#!variable!file_uuid!#" />
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td colspan="5">
&nbsp;
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="9">
&nbsp;
</td>
</tr>
<!-- end file-list-manager -->
<!-- start file-list-manager-confirm-button -->
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#" class="button"> &nbsp;
<input type="hidden" name="save" id="save" value="true">
<!-- end file-list-manager-confirm-button -->
<!-- start file-list-manager-anvil-entry -->
<tr>
<td class="available" style="text-align: right;">
#!variable!anvil_name!#: &nbsp;
</td>
<td style="text-align: left;">
#!variable!anvil_description!#
</td>
<td>
<!-- Synced -->
<input type="radio" name="#!variable!radio_name!#" id="#!variable!radio_name!#" value="true" class="radio" #!variable!true_checked!#>
</td>
<td>
<!-- Remove -->
<input type="radio" name="#!variable!radio_name!#" id="#!variable!radio_name!#" value="false" class="radio" #!variable!false_checked!#>
</td>
<td>
&nbsp;
</td>
</tr>
<!-- end file-list-manager-anvil-entry -->
<!-- start file-list-manager-no-anvils -->
<tr>
<td>
&nbsp;
</td>
<td colspan="3" class="subtle_text">
#!string!striker_0283!#
</td>
<td>
&nbsp;
</td>
</tr>
<!-- end file-list-manager-no-anvils -->
<!-- start upload_header -->
<!DOCTYPE html>
<html lang="en_CA">

@ -62,6 +62,13 @@ body {
white-space: nowrap;
}
.row_header {
text-align: right;
color: #9ba0a5;
padding: 0.15em;
white-space: nowrap;
}
.column_header_veritcal {
text-align: left;
vertical-align: bottom;
@ -225,6 +232,10 @@ input[type=text].input_alert, input[type=number].input_alert, select.input_alert
border: 1px solid #ff3f3f;
}
input[type=text].input_alert_fixed, input[type=number].input_alert_fixed, select.input_alert_fixed {
border: 1px solid #ff3f3f;
}
.input_required {
color: 1px solid #3ed688;
}
@ -237,6 +248,11 @@ input[type=text].input_clear, input[type=number].input_clear, select.input_clear
border: 1px solid #9ba0a5;
}
input[type=text].input_clear_fixed, input[type=number].input_clear_fixed, select.input_clear_fixed {
border: 1px solid #9ba0a5;
font-family: 'Dejavu Sans Mono', Courier;
}
.login {
width: 600px;
height: 50px;
@ -520,9 +536,22 @@ tr.data_row {
text-align: center;
}
.risky_click {
color: #f06075;
font-weight: bold;
}
table.list {
/* margin-left: auto; */
/* margin-right: auto; */
padding-top: 0.2em;
padding-bottom: 0.2em;
padding-left: 0.4em;
padding-right: 0.4em;
border: 1px dotted #7f7f7f;
}
table.manager {
width: 100%;
text-align: center;
padding-top: 0.2em;
padding-bottom: 0.2em;
padding-left: 0.4em;

@ -250,6 +250,9 @@ The error was:
<key name="error_0175">Unable to pull the file: [#!variable!file!#], we're not an Anvil! member.</key>
<key name="error_0176">The downloaded file's md5sum: [#!variable!local_md5sum!#] doesn't match what is expected: [#!variable!file_md5sum!#]. The file has been removed. We'll wait for a minute and then exit, and the download will be attempted again.</key>
<key name="error_0177">Something went wrong and the file wasn't downloaded. More information should be in the logs. We'll wait for a minute and then exit, and the download will be attempted again.</key>
<key name="error_0178">Unable to purge the file because a file UUID wasn't set (or failed to parse) from the 'job_data' in the job: [#!variable!job_uuid!#].</key>
<key name="error_0179">Unable to purge a file as the file UUID: [#!variable!file_uuid!#] is either invalid or doesn't exist in the database.</key>
<key name="error_0180">Failed to delete: [#!variable!file_path!#]. The error returned was: [#!variable!error!#]. There may be more details in the logs.</key>
<!-- Table headers -->
<key name="header_0001">Current Network Interfaces and States</key>
@ -298,6 +301,13 @@ The error was:
<key name="header_0044">File Type</key>
<key name="header_0045">File Size</key>
<key name="header_0046">md5sum</key>
<key name="header_0047">New File Name</key>
<key name="header_0048">New File Type</key>
<key name="header_0049">Purge File</key>
<key name="header_0050">#!string!brand_0006!# List</key>
<key name="header_0051">Synced</key>
<key name="header_0052">Remove</key>
<key name="header_0053">#!string!brand_0006!# Name</key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -437,6 +447,10 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0131">Reconnecting will start a synchonization of the database. This step might take a while to complete, please be patient.</key>
<key name="job_0132">Sync Uploaded File</key>
<key name="job_0133">This moves an uploaded file from the: [#!data!path::directories::shared::incoming!#] directory to: [#!data!path::directories::shared::files!#] directory, adds it to the Anvil! database, and pushed it out to other systems.</key>
<key name="job_0134">Successfully deleted the file: [#!variable!file_path!#].</key>
<key name="job_0135">No need to delete the file: [#!variable!file_path!#], it already doesn't exist.</key>
<key name="job_0136">Purge File.</key>
<key name="job_0137">This askes all systems to delete the associated file from their systems.</key>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>
@ -1404,6 +1418,7 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t
<key name="message_0200">Beginning rsync from: [#!variable!source_file!#] to: [#!variable!target_directory!#], please be patient...</key>
<key name="message_0201">Download appears to be complete, calculating md5sum to verify, please be patient...</key>
<key name="message_0202">Success! The file has been successfully downloaded.</key>
<key name="message_0203">Processing a file purge.</key>
<!-- Success messages shown to the user -->
<key name="ok_0001">Saved the mail server information successfully!</key>
@ -1713,7 +1728,10 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0278">This is a condition record, used by programs like scan agents to track how long a condition has existed for.</key>
<key name="striker_0279">This indicated why a machine was powered off. This is used by ScanCore to decide if or when to power up the target host.</key>
<key name="striker_0280">Storage Pool #!variable!number!#</key> <!-- This is used for auto-generated VG groups -->
<key name="message_0281">Manage this file.</key>
<key name="striker_0281">Manage this file.</key>
<key name="striker_0282">This will remove the file from all systems.</key>
<key name="striker_0283">There are no #!string!brand_0006!# configured yet. Existing files will automatically sync to new clusters.</key>
<key name="striker_0284">Cancel</key>
<!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key>
@ -1801,6 +1819,11 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="title_0007">- Notice Cleared!</key>
<key name="title_0008">- Info Cleared!</key>
<!-- These are used for descriptions of things -->
<key name="type_0001">ISO (optical disc)</key>
<key name="type_0002">Script (program)</key>
<key name="type_0003">Other file type</key>
<!-- These are units, words and so on used when displaying information. -->
<key name="unit_0001">Yes</key>
<key name="unit_0002">No</key>

@ -67,6 +67,10 @@ if ($anvil->data->{switches}{'job-uuid'})
{
process_pull_file($anvil);
}
if ($anvil->data->{jobs}{job_name} eq "storage::purge")
{
process_purge_file($anvil);
}
# Job data will be in $anvil->data->{jobs}{job_data}
}
@ -84,6 +88,100 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub process_purge_file
{
my ($anvil) = @_;
$anvil->Job->update_progress({
progress => $anvil->data->{sys}{progress},
message => "message_0191",
});
$anvil->Database->get_files({debug => 3});
$anvil->Database->get_file_locations({debug => 3});
my $file_uuid = ($anvil->data->{jobs}{job_data} =~ /file_uuid=(.*)$/)[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_uuid => $file_uuid }});
if (not $file_uuid)
{
# Can't do anything, file wasn't parsed.
$anvil->Job->update_progress({
progress => 100,
message => "error_0178,!!job_uuid!".$anvil->data->{switches}{'job-uuid'}."!!",
job_status => "failed",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => 'err', key => "error_0178", variables => { job_uuid => $anvil->data->{switches}{'job-uuid'} }});
$anvil->nice_exit({exit_code => 1});
}
elsif (not exists $anvil->data->{files}{file_uuid}{$file_uuid})
{
# File UUID doesn't appear to be valid.
$anvil->Job->update_progress({
progress => 100,
message => "error_0179,!!file_uuid!".$file_uuid."!!",
job_status => "failed",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => 'err', key => "error_0179", variables => { file_uuid => $file_uuid }});
$anvil->nice_exit({exit_code => 1});
}
my $file_name = $anvil->data->{files}{file_uuid}{$file_uuid}{file_name};
my $file_directory = $anvil->data->{files}{file_uuid}{$file_uuid}{file_directory};
my $file_path = $file_directory."/".$file_name;
my $file_type = $anvil->data->{files}{file_uuid}{$file_uuid}{file_type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:file_name' => $file_name,
's2:file_directory' => $file_directory,
's3:file_path' => $file_path,
's4:file_type' => $file_type,
}});
# From here, we'll unlink if it exists. If it doesn't exist, we still exit sucessfully.
if (-e $file_path)
{
# Remove it
unlink $file_path;
if (-e $file_path)
{
# Failed.
my $error = $!;
$anvil->Job->update_progress({
progress => 100,
message => "error_0180,!!file_path!".$file_path."!!,!!error!".$error."!!",
job_status => "failed",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => 'err', key => "error_0180", variables => {
file_path => $file_path,
error => $error,
}});
$anvil->nice_exit({exit_code => 1});
}
else
{
# Success!
$anvil->Job->update_progress({
progress => 100,
message => "job_0134,!!file_path!".$file_path."!!",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => 'err', key => "job_0134", variables => { file_path => $file_path }});
$anvil->nice_exit({exit_code => 0});
}
}
else
{
# Doesn't exist, nothing to do.
$anvil->Job->update_progress({
progress => 100,
message => "job_0135,!!file_path!".$file_path."!!",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => 'err', key => "job_0135", variables => { file_path => $file_path }});
$anvil->nice_exit({exit_code => 0});
}
return(0);
}
sub process_incoming_file
{
my ($anvil) = @_;

Loading…
Cancel
Save