|
|
@ -2389,6 +2389,10 @@ If not passed, a check will be made to see if an existing entry is found for C<< |
|
|
|
|
|
|
|
|
|
|
|
This is the file's name. |
|
|
|
This is the file's name. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=head3 file_directory (required) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This is the directory that the file is in. This is used to avoid conflict if two files of the same name exist in two places but are otherwise different. |
|
|
|
|
|
|
|
|
|
|
|
=head3 file_size (required) |
|
|
|
=head3 file_size (required) |
|
|
|
|
|
|
|
|
|
|
|
This is the file's size in bytes. It is recorded as a quick way to determine if the file has changed on disk. |
|
|
|
This is the file's size in bytes. It is recorded as a quick way to determine if the file has changed on disk. |
|
|
@ -2418,6 +2422,7 @@ sub insert_or_update_files |
|
|
|
my $line = defined $parameter->{line} ? $parameter->{line} : ""; |
|
|
|
my $line = defined $parameter->{line} ? $parameter->{line} : ""; |
|
|
|
my $file_uuid = defined $parameter->{file_uuid} ? $parameter->{file_uuid} : ""; |
|
|
|
my $file_uuid = defined $parameter->{file_uuid} ? $parameter->{file_uuid} : ""; |
|
|
|
my $file_name = defined $parameter->{file_name} ? $parameter->{file_name} : ""; |
|
|
|
my $file_name = defined $parameter->{file_name} ? $parameter->{file_name} : ""; |
|
|
|
|
|
|
|
my $file_directory = defined $parameter->{file_directory} ? $parameter->{file_directory} : ""; |
|
|
|
my $file_size = defined $parameter->{file_size} ? $parameter->{file_size} : ""; |
|
|
|
my $file_size = defined $parameter->{file_size} ? $parameter->{file_size} : ""; |
|
|
|
my $file_md5sum = defined $parameter->{file_md5sum} ? $parameter->{file_md5sum} : ""; |
|
|
|
my $file_md5sum = defined $parameter->{file_md5sum} ? $parameter->{file_md5sum} : ""; |
|
|
|
my $file_type = defined $parameter->{file_type} ? $parameter->{file_type} : ""; |
|
|
|
my $file_type = defined $parameter->{file_type} ? $parameter->{file_type} : ""; |
|
|
@ -2425,6 +2430,7 @@ sub insert_or_update_files |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
file_uuid => $file_uuid, |
|
|
|
file_uuid => $file_uuid, |
|
|
|
file_name => $file_name, |
|
|
|
file_name => $file_name, |
|
|
|
|
|
|
|
file_directory => $file_directory, |
|
|
|
file_size => $file_size, |
|
|
|
file_size => $file_size, |
|
|
|
file_md5sum => $file_md5sum, |
|
|
|
file_md5sum => $file_md5sum, |
|
|
|
file_type => $file_type, |
|
|
|
file_type => $file_type, |
|
|
@ -2443,6 +2449,12 @@ sub insert_or_update_files |
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_files()", parameter => "file_name" }}); |
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_files()", parameter => "file_name" }}); |
|
|
|
return(""); |
|
|
|
return(""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (not $file_directory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
# Throw an error and exit. |
|
|
|
|
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_files()", parameter => "file_directory" }}); |
|
|
|
|
|
|
|
return(""); |
|
|
|
|
|
|
|
} |
|
|
|
if (not $file_md5sum) |
|
|
|
if (not $file_md5sum) |
|
|
|
{ |
|
|
|
{ |
|
|
|
# Throw an error and exit. |
|
|
|
# Throw an error and exit. |
|
|
@ -2524,6 +2536,7 @@ INSERT INTO |
|
|
|
( |
|
|
|
( |
|
|
|
file_uuid, |
|
|
|
file_uuid, |
|
|
|
file_name, |
|
|
|
file_name, |
|
|
|
|
|
|
|
file_directory, |
|
|
|
file_size, |
|
|
|
file_size, |
|
|
|
file_md5sum, |
|
|
|
file_md5sum, |
|
|
|
file_type, |
|
|
|
file_type, |
|
|
@ -2532,6 +2545,7 @@ INSERT INTO |
|
|
|
) VALUES ( |
|
|
|
) VALUES ( |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_uuid).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_uuid).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_name).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_name).", |
|
|
|
|
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_directory).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_size).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_size).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_md5sum).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_md5sum).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_type).", |
|
|
|
".$anvil->data->{sys}{database}{use_handle}->quote($file_type).", |
|
|
@ -2548,6 +2562,7 @@ INSERT INTO |
|
|
|
my $query = " |
|
|
|
my $query = " |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
file_name, |
|
|
|
file_name, |
|
|
|
|
|
|
|
file_directory, |
|
|
|
file_size, |
|
|
|
file_size, |
|
|
|
file_md5sum, |
|
|
|
file_md5sum, |
|
|
|
file_type, |
|
|
|
file_type, |
|
|
@ -2574,12 +2589,14 @@ WHERE |
|
|
|
foreach my $row (@{$results}) |
|
|
|
foreach my $row (@{$results}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
my $old_file_name = $row->[0]; |
|
|
|
my $old_file_name = $row->[0]; |
|
|
|
|
|
|
|
my $old_file_directory = $row->[1]; |
|
|
|
my $old_file_size = $row->[1]; |
|
|
|
my $old_file_size = $row->[1]; |
|
|
|
my $old_file_md5sum = $row->[2]; |
|
|
|
my $old_file_md5sum = $row->[2]; |
|
|
|
my $old_file_type = $row->[3]; |
|
|
|
my $old_file_type = $row->[3]; |
|
|
|
my $old_file_mtime = $row->[4]; |
|
|
|
my $old_file_mtime = $row->[4]; |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
old_file_name => $old_file_name, |
|
|
|
old_file_name => $old_file_name, |
|
|
|
|
|
|
|
old_file_directory => $old_file_directory, |
|
|
|
old_file_size => $old_file_size, |
|
|
|
old_file_size => $old_file_size, |
|
|
|
old_file_md5sum => $old_file_md5sum, |
|
|
|
old_file_md5sum => $old_file_md5sum, |
|
|
|
old_file_type => $old_file_type, |
|
|
|
old_file_type => $old_file_type, |
|
|
@ -2588,6 +2605,7 @@ WHERE |
|
|
|
|
|
|
|
|
|
|
|
# Anything change? |
|
|
|
# Anything change? |
|
|
|
if (($old_file_name ne $file_name) or |
|
|
|
if (($old_file_name ne $file_name) or |
|
|
|
|
|
|
|
($old_file_directory ne $file_directory) or |
|
|
|
($old_file_size ne $file_size) or |
|
|
|
($old_file_size ne $file_size) or |
|
|
|
($old_file_md5sum ne $file_md5sum) or |
|
|
|
($old_file_md5sum ne $file_md5sum) or |
|
|
|
($old_file_mtime ne $file_mtime) or |
|
|
|
($old_file_mtime ne $file_mtime) or |
|
|
@ -2599,6 +2617,7 @@ UPDATE |
|
|
|
files |
|
|
|
files |
|
|
|
SET |
|
|
|
SET |
|
|
|
file_name = ".$anvil->data->{sys}{database}{use_handle}->quote($file_name).", |
|
|
|
file_name = ".$anvil->data->{sys}{database}{use_handle}->quote($file_name).", |
|
|
|
|
|
|
|
file_directory = ".$anvil->data->{sys}{database}{use_handle}->quote($file_directory).", |
|
|
|
file_size = ".$anvil->data->{sys}{database}{use_handle}->quote($file_size).", |
|
|
|
file_size = ".$anvil->data->{sys}{database}{use_handle}->quote($file_size).", |
|
|
|
file_md5sum = ".$anvil->data->{sys}{database}{use_handle}->quote($file_md5sum).", |
|
|
|
file_md5sum = ".$anvil->data->{sys}{database}{use_handle}->quote($file_md5sum).", |
|
|
|
file_type = ".$anvil->data->{sys}{database}{use_handle}->quote($file_type).", |
|
|
|
file_type = ".$anvil->data->{sys}{database}{use_handle}->quote($file_type).", |
|
|
@ -5347,6 +5366,9 @@ sub query |
|
|
|
$anvil->Database->check_lock_age({debug => $debug}); |
|
|
|
$anvil->Database->check_lock_age({debug => $debug}); |
|
|
|
|
|
|
|
|
|
|
|
# Do I need to log the transaction? |
|
|
|
# Do I need to log the transaction? |
|
|
|
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { |
|
|
|
|
|
|
|
"sys::database::log_transactions" => $anvil->data->{sys}{database}{log_transactions}, |
|
|
|
|
|
|
|
}}); |
|
|
|
if ($anvil->data->{sys}{database}{log_transactions}) |
|
|
|
if ($anvil->data->{sys}{database}{log_transactions}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$anvil->Log->entry({source => $source, line => $line, secure => $secure, level => 0, key => "log_0074", variables => { |
|
|
|
$anvil->Log->entry({source => $source, line => $line, secure => $secure, level => 0, key => "log_0074", variables => { |
|
|
@ -5361,6 +5383,7 @@ sub query |
|
|
|
server => $say_server, |
|
|
|
server => $say_server, |
|
|
|
db_error => $DBI::errstr, |
|
|
|
db_error => $DBI::errstr, |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { DBreq => $DBreq }}); |
|
|
|
|
|
|
|
|
|
|
|
# Execute on the query |
|
|
|
# Execute on the query |
|
|
|
$DBreq->execute() or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0076", variables => { |
|
|
|
$DBreq->execute() or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0076", variables => { |
|
|
|