This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.18 by this push:
     new f2c17756578 fix: cleanup directory if empty after removal of snapshot 
(#8002)
f2c17756578 is described below

commit f2c17756578927dfdfa566aafd2efdef09243d5b
Author: Vishesh <[email protected]>
AuthorDate: Fri Sep 29 18:51:53 2023 +0530

    fix: cleanup directory if empty after removal of snapshot (#8002)
    
    Co-authored-by: Daniel Augusto Veronezi Salvador 
<[email protected]>
---
 .../cloudstack/storage/resource/NfsSecondaryStorageResource.java   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
 
b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index e16926e76dc..d8f7395c885 100644
--- 
a/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ 
b/services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -2050,6 +2050,13 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
                 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);
+            }
             return new Answer(cmd, true, null);
         } else if (dstore instanceof S3TO) {
             final S3TO s3 = (S3TO)dstore;

Reply via email to