Ver código fonte

Ensure Project Manager properly deletes restricted project folder when needed (#18037)

* adding necessary changes to ensure Project Manager properly deletes restricted project folder from standard O3DE user folder if present

Signed-off-by: T.J. Kotha <[email protected]>

* updating deletion logic to check for exact folder traversal first

Signed-off-by: T.J. Kotha <[email protected]>

---------

Signed-off-by: T.J. Kotha <[email protected]>
T.J. Kotha 1 ano atrás
pai
commit
c9c732b5d9

+ 1 - 0
Code/Tools/ProjectManager/Source/ProjectInfo.h

@@ -55,6 +55,7 @@ namespace O3DE::ProjectManager
         QString m_iconPath;
         QString m_requirements;
         QString m_license;
+        QString m_restricted;
         QStringList m_userTags;
 
         QStringList m_requiredGemDependencies;

+ 15 - 1
Code/Tools/ProjectManager/Source/ProjectUtils.cpp

@@ -23,6 +23,7 @@
 #include <QGuiApplication>
 #include <QProgressDialog>
 #include <QSpacerItem>
+#include <QStandardPaths>
 #include <QGridLayout>
 #include <QTextEdit>
 #include <QByteArray>
@@ -461,8 +462,21 @@ namespace O3DE::ProjectManager
             if (projectDirectory.exists())
             {
                 // Check if there is an actual project here or just force it
-                if (force || PythonBindingsInterface::Get()->GetProject(path).IsSuccess())
+                AZ::Outcome<ProjectInfo> pInfo = PythonBindingsInterface::Get()->GetProject(path);
+                if (force || pInfo.IsSuccess())
                 {
+                    //determine if we have a restricted directory to worry about
+                    if (!pInfo.GetValue().m_restricted.isEmpty())
+                    {
+                        QDir restrictedDirectory(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
+                        
+                        if (restrictedDirectory.cd("O3DE/Restricted/Projects") &&
+                            restrictedDirectory.cd(pInfo.GetValue().m_restricted) &&
+                            !restrictedDirectory.isEmpty())
+                        {
+                            restrictedDirectory.removeRecursively();
+                        }
+                    }
                     return projectDirectory.removeRecursively();
                 }
             }

+ 1 - 0
Code/Tools/ProjectManager/Source/PythonBindings.cpp

@@ -1109,6 +1109,7 @@ namespace O3DE::ProjectManager
         projectInfo.m_license = Py_To_String_Optional(projectData, "license", projectInfo.m_license);
         projectInfo.m_iconPath = Py_To_String_Optional(projectData, "icon", ProjectPreviewImagePath);
         projectInfo.m_engineName = Py_To_String_Optional(projectData, "engine", projectInfo.m_engineName);
+        projectInfo.m_restricted = Py_To_String_Optional(projectData, "restricted", projectInfo.m_restricted);
         if (projectData.contains("user_tags"))
         {
             for (auto tag : projectData["user_tags"])