Skip to content

Commit f2c1775

Browse files
fix: cleanup directory if empty after removal of snapshot (#8002)
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
1 parent 221f863 commit f2c1775

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,13 @@ protected Answer deleteSnapshot(final DeleteCommand cmd) {
20502050
s_logger.warn(details);
20512051
return new Answer(cmd, false, details);
20522052
}
2053+
2054+
// delete the directory if it is empty
2055+
if (snapshotDir.isDirectory() && snapshotDir.list().length == 0 && !snapshotDir.delete()) {
2056+
details = String.format("Unable to delete directory [%s] at path [%s].", snapshotDir.getName(), snapshotPath);
2057+
s_logger.debug(details);
2058+
return new Answer(cmd, false, details);
2059+
}
20532060
return new Answer(cmd, true, null);
20542061
} else if (dstore instanceof S3TO) {
20552062
final S3TO s3 = (S3TO)dstore;

0 commit comments

Comments
 (0)