Browse Source

Fixes #13111 and #15320 (#15358)

Signed-off-by: John Jones-Steele <[email protected]>
John Jones-Steele 2 years ago
parent
commit
043b79bae8

+ 4 - 3
Code/Framework/AzFramework/AzFramework/Asset/AssetProcessorMessages.cpp

@@ -1515,10 +1515,11 @@ namespace AzFramework
         }
 
         AssetChangeReportRequest::AssetChangeReportRequest(
-            const AZ::OSString& fromPath, const AZ::OSString& toPath, ChangeType changeType)
+            const AZ::OSString& fromPath, const AZ::OSString& toPath, ChangeType changeType, bool isFolder)
             : m_fromPath(fromPath)
             , m_toPath(toPath)
             , m_type(changeType)
+            , m_isFolder(isFolder)
         {
         }
 
@@ -1537,8 +1538,8 @@ namespace AzFramework
                     ->Version(1)
                     ->Field("FromPath", &AssetChangeReportRequest::m_fromPath)
                     ->Field("ToPath", &AssetChangeReportRequest::m_toPath)
-                    ->Field("ChangeType", &AssetChangeReportRequest::m_type);
-
+                    ->Field("ChangeType", &AssetChangeReportRequest::m_type)
+                    ->Field("IsFolder", &AssetChangeReportRequest::m_isFolder);
             }
         }
 

+ 2 - 1
Code/Framework/AzFramework/AzFramework/Asset/AssetProcessorMessages.h

@@ -1291,12 +1291,13 @@ namespace AzFramework
 
             // The default constructor is only required for the SerializeContext.
             AssetChangeReportRequest() = default;
-            AssetChangeReportRequest(const AZ::OSString& fromPath, const AZ::OSString& toPath, ChangeType changeType = ChangeType::Move);
+            AssetChangeReportRequest(const AZ::OSString& fromPath, const AZ::OSString& toPath, ChangeType changeType = ChangeType::Move, bool isFolder = false);
             unsigned int GetMessageType() const override;
 
             AZ::OSString m_fromPath;
             AZ::OSString m_toPath;
             ChangeType m_type;
+            bool m_isFolder;
         };
 
         class AssetChangeReportResponse

+ 2 - 2
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserViewUtils.cpp

@@ -247,7 +247,7 @@ namespace AzToolsFramework
                         fromPath = item->GetFullPath();
                     }
                     AssetChangeReportRequest request(
-                        AZ::OSString(fromPath.c_str()), AZ::OSString(""), AssetChangeReportRequest::ChangeType::CheckDelete);
+                        AZ::OSString(fromPath.c_str()), AZ::OSString(""), AssetChangeReportRequest::ChangeType::CheckDelete, isFolder);
                     AssetChangeReportResponse response;
 
                     if (SendRequest(request, response))
@@ -300,7 +300,7 @@ namespace AzToolsFramework
                         if (canDelete)
                         {
                             AssetChangeReportRequest deleteRequest(
-                                AZ::OSString(fromPath.c_str()), AZ::OSString(""), AssetChangeReportRequest::ChangeType::Delete);
+                                AZ::OSString(fromPath.c_str()), AZ::OSString(""), AssetChangeReportRequest::ChangeType::Delete, isFolder);
                             AssetChangeReportResponse deleteResponse;
                             if (SendRequest(deleteRequest, deleteResponse))
                             {

+ 12 - 2
Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.cpp

@@ -124,14 +124,24 @@ namespace
                 }
                 case AssetChangeReportRequest::ChangeType::CheckDelete:
                 {
-                    auto resultCheck = relocationInterface->Delete(messageData.m_message->m_fromPath, RelocationParameters_PreviewOnlyFlag | RelocationParameters_AllowDependencyBreakingFlag);
+                    auto flags = RelocationParameters_PreviewOnlyFlag | RelocationParameters_AllowDependencyBreakingFlag;
+                    if (messageData.m_message->m_isFolder)
+                    {
+                        flags |= RelocationParameters_RemoveEmptyFoldersFlag;
+                    }
+                    auto resultCheck = relocationInterface->Delete(messageData.m_message->m_fromPath, flags);
 
                     BuildReport(relocationInterface, resultCheck, lines);
                     break;
                 }
                 case AssetChangeReportRequest::ChangeType::Delete:
                 {
-                    auto resultDelete = relocationInterface->Delete(messageData.m_message->m_fromPath, RelocationParameters_AllowDependencyBreakingFlag);
+                    int flags = RelocationParameters_AllowDependencyBreakingFlag;
+                    if (messageData.m_message->m_isFolder)
+                    {
+                        flags |= RelocationParameters_RemoveEmptyFoldersFlag;
+                    }
+                    auto resultDelete = relocationInterface->Delete(messageData.m_message->m_fromPath, flags);
 
                     BuildReport(relocationInterface, resultDelete, lines);
                     break;