From ed91435211330a3e6d40efdc60cf8dec3a93bb05 Mon Sep 17 00:00:00 2001 From: digimer Date: Sat, 30 Sep 2023 00:13:56 -0400 Subject: [PATCH] Fixed a bug where duplicate files weren't actually being deleted. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 6c80f9a8..dade1c1d 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -3835,7 +3835,7 @@ WHERE if ($delete_file_uuid) { # Log which we're deleting - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0813", variables => { full_uuid => $delete_file_uuid }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0813", variables => { file_uuid => $delete_file_uuid }}); # As we delete file_locations, we need to make sure that there are # file_location_file_uuid entries for the other file. @@ -3844,11 +3844,19 @@ WHERE my $query = "DELETE FROM history.file_locations WHERE file_location_file_uuid = ".$anvil->Database->quote($delete_file_uuid).";"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); - $anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__}); + $anvil->Database->write({debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__}); $query = "DELETE FROM file_locations WHERE file_location_file_uuid = ".$anvil->Database->quote($delete_file_uuid).";"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); - $anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__}); + $anvil->Database->write({debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__}); + + $query = "DELETE FROM history.files WHERE file_uuid = ".$anvil->Database->quote($delete_file_uuid).";"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); + $anvil->Database->write({debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__}); + + $query = "DELETE FROM files WHERE file_uuid = ".$anvil->Database->quote($delete_file_uuid).";"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); + $anvil->Database->write({debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__}); delete $anvil->data->{files}{file_uuid}{$delete_file_uuid}; next;