Copilot commented on code in PR #11970:
URL: https://github.com/apache/cloudstack/pull/11970#discussion_r2489319182


##########
server/src/main/java/com/cloud/api/query/dao/TemplateJoinDaoImpl.java:
##########
@@ -162,26 +163,20 @@ protected TemplateJoinDaoImpl() {
     }
 
     private String getTemplateStatus(TemplateJoinVO template) {
-        String templateStatus = null;
-        if (template.getDownloadState() != Status.DOWNLOADED) {
-            templateStatus = "Processing";
-            if (template.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
-                if (template.getDownloadPercent() == 100) {
-                    templateStatus = "Installing Template";
-                } else {
-                    templateStatus = template.getDownloadPercent() + "% 
Downloaded";
-                }
-            } else if (template.getDownloadState() == Status.BYPASSED) {
-                templateStatus = "Bypassed Secondary Storage";
-            } else if (template.getErrorString() == null) {
-                templateStatus = template.getTemplateState().toString();
+        if (template.getDownloadState() == Status.DOWNLOADED) {
+            return "Download Complete";
+        }
+        String templateStatus = "Processing";
+        if (template.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
+            if (template.getDownloadPercent() == 100) {
+                templateStatus = "Installing Template";
             } else {
-                templateStatus = template.getErrorString().trim();
+                templateStatus = template.getDownloadPercent() + "% 
Downloaded";
             }
-        } else if (template.getDownloadState() == Status.DOWNLOADED) {
-            templateStatus = "Download Complete";
-        } else {
-            templateStatus = "Successfully Installed";
+        } else if (template.getDownloadState() == Status.BYPASSED) {
+            templateStatus = "Bypassed Secondary Storage";
+        } else if (StringUtils.isNotBlank(template.getErrorString())) {
+            templateStatus = template.getErrorString().trim();

Review Comment:
   The original code had a fallback branch that returned 
`template.getTemplateState().toString()` when `errorString` was null and the 
download state was not DOWNLOADED, DOWNLOAD_IN_PROGRESS, or BYPASSED. This 
logic has been removed. For download states like CREATED, UPLOADED, CREATING, 
UNKNOWN, DOWNLOAD_ERROR, etc., the method will now return 'Processing' instead 
of the template state. If this is intentional, consider adding a comment 
explaining the change; otherwise, restore the original behavior by adding: `} 
else { templateStatus = template.getTemplateState().toString(); }`
   ```suggestion
               templateStatus = template.getErrorString().trim();
           } else {
               templateStatus = template.getTemplateState().toString();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to