From 2c1788e2e46291a6d9340f2b2a470df691c74d80 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 8 Aug 2021 10:39:48 +0200 Subject: [PATCH] FileOperation: Don't follow symlinks Deleting a symlink via "FileOperation Delete" should not recursively delete whatever the symlink is pointing to. Same basic idea applies to the Copy and Move operations. --- Userland/Services/FileOperation/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp index 96ec507151..14bbab1bd5 100644 --- a/Userland/Services/FileOperation/main.cpp +++ b/Userland/Services/FileOperation/main.cpp @@ -76,7 +76,7 @@ static void report_warning(String message) static bool collect_copy_work_items(String const& source, String const& destination, Vector& items) { struct stat st = {}; - if (stat(source.characters(), &st) < 0) { + if (lstat(source.characters(), &st) < 0) { auto original_errno = errno; report_error(String::formatted("stat: {}", strerror(original_errno))); return false; @@ -130,7 +130,7 @@ int perform_copy(Vector const& sources, String const& destination) static bool collect_move_work_items(String const& source, String const& destination, Vector& items) { struct stat st = {}; - if (stat(source.characters(), &st) < 0) { + if (lstat(source.characters(), &st) < 0) { auto original_errno = errno; report_error(String::formatted("stat: {}", strerror(original_errno))); return false; @@ -191,7 +191,7 @@ int perform_move(Vector const& sources, String const& destination) static bool collect_delete_work_items(String const& source, Vector& items) { struct stat st = {}; - if (stat(source.characters(), &st) < 0) { + if (lstat(source.characters(), &st) < 0) { auto original_errno = errno; report_error(String::formatted("stat: {}", strerror(original_errno))); return false;