From 03f0cdad84997b0fe54524f7ffcf926f69829da8 Mon Sep 17 00:00:00 2001 From: Digimer Date: Wed, 5 Oct 2022 20:56:57 -0400 Subject: [PATCH] Updated anvil-manage-files to only remove files from /mnt/shared/files Signed-off-by: Digimer --- tools/anvil-manage-files | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/anvil-manage-files b/tools/anvil-manage-files index 76f2b6ee..cd32f45f 100755 --- a/tools/anvil-manage-files +++ b/tools/anvil-manage-files @@ -932,6 +932,10 @@ sub check_for_deletes my $query = "SELECT file_uuid, file_directory || '/' || file_name AS full_path FROM files WHERE file_type = 'DELETED';"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); + # This will be used to make sure we only delete from files + my $files_directory = $anvil->data->{path}{directories}{shared}{files}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { files_directory => $files_directory }}); + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); my $count = @{$results}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -947,6 +951,9 @@ sub check_for_deletes 's2:full_path' => $full_path, }}); + # Only delete if the file is in the shared directory. + next if $full_path !~ /^$files_directory/; + # Get rid of it (if it actually exists). if (-e $full_path) {