Fix Remove(), RemoveAll() to delete symlink properly 75/224175/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 7 Feb 2020 01:48:12 +0000 (10:48 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 7 Feb 2020 01:48:12 +0000 (10:48 +0900)
Even if the file or directory that symlink points not exist, Remove()
and RemoveAll() should delete symlink file.
Note that bf::remove() and bf::remove_all() delete symbolic link itself.

Change-Id: I37fbeea897dc12f3b355e24b8763abaa304c5a02
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/utils/file_util.cc

index 0978cd0..6595256 100644 (file)
@@ -324,7 +324,7 @@ bool RemoveBackup(const bf::path& path) {
 }
 
 bool RemoveAll(const bf::path& path) {
-  if (!exists(path))
+  if (!exists(path) && !bf::is_symlink(bf::symlink_status(path)))
     return true;
 
   bs::error_code error;
@@ -339,7 +339,7 @@ bool RemoveAll(const bf::path& path) {
 }
 
 bool Remove(const bf::path& path) {
-  if (!exists(path))
+  if (!exists(path) && !bf::is_symlink(bf::symlink_status(path)))
     return true;
 
   bs::error_code error;