You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "harikrishna-patnala (via GitHub)" <gi...@apache.org> on 2023/09/26 22:40:33 UTC

[GitHub] [cloudstack] harikrishna-patnala commented on a diff in pull request #8002: fix: cleanup directory if empty after removal of snapshot

harikrishna-patnala commented on code in PR #8002:
URL: https://github.com/apache/cloudstack/pull/8002#discussion_r1337850036


##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
##########
@@ -2050,6 +2050,13 @@ protected Answer deleteSnapshot(final DeleteCommand cmd) {
                 s_logger.warn(details);
                 return new Answer(cmd, false, details);
             }
+
+            // delete the directory if it is empty
+            if (snapshotDir.isDirectory() && snapshotDir.list().length == 0 && !snapshotDir.delete()) {
+                details = String.format("Unable to delete directory [%s] at path [%s].", snapshotDir.getName(), snapshotPath);
+                s_logger.debug(details);
+                return new Answer(cmd, false, details);

Review Comment:
   Usually this should not happen, but we don't have fail the operation if the directory deletion fails I think. What do you say @vishesh92 



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org