summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2023-04-17 09:22:12 -0700
committerCorey Berla <corey@berla.me>2023-04-24 14:20:54 +0000
commitf20441f7ed57c12be72888e8579f1e125e8317d5 (patch)
tree84040259ebbff2f650bc80c0025004d364d3ad35
parent7c9df6a7fc7d4c5b5a00efe4fb6314a16251a05e (diff)
downloadnautilus-f20441f7ed57c12be72888e8579f1e125e8317d5.tar.gz
file-operations: Handle errors properly in delete_files_recursively
The callback function in delete_files_recursively() uses the results from its GError to determine if it should call nautilus_file_changes_queue_file_removed() (which ultimately calls the list-base remove_file() function). This normally, works as expected, except when one of the child files fails to delete. We check for recursive deletion failures, but we never get the error that caused that failure. This means that the callback function will believe that the parent folder was deleted (when it really wasn't), and the item will disappear from the view in Nautilus because of the call to nautilus_file_changes_queue_file_removed(). If we weren't successful at deleting, but there's no error, that means that a recursive call to delete failed. In that case let's generate our own error. Fixes: #517
-rw-r--r--src/nautilus-file-operations.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index cce3b2548..59341d83e 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -2002,6 +2002,14 @@ delete_file_recursively (GFile *file,
if (callback)
{
+ if (!success && error == NULL)
+ {
+ /* Enumeration succeeded, but we've failed to delete at least one child. */
+ error = g_error_new (G_IO_ERROR,
+ G_IO_ERROR_NOT_EMPTY,
+ _("Failed to delete all child files"));
+ }
+
callback (file, error, callback_data);
}