Skip to content

Commit f70b42a

Browse files
committed
Merge release branch 4.18 to main
* 4.18: fix: cleanup directory if empty after removal of snapshot (#8002)
2 parents 9f5c3ff + f2c1775 commit f70b42a

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
@@ -2076,6 +2076,13 @@ protected Answer deleteSnapshot(final DeleteCommand cmd) {
20762076
s_logger.warn(details);
20772077
return new Answer(cmd, false, details);
20782078
}
2079+
2080+
// delete the directory if it is empty
2081+
if (snapshotDir.isDirectory() && snapshotDir.list().length == 0 && !snapshotDir.delete()) {
2082+
details = String.format("Unable to delete directory [%s] at path [%s].", snapshotDir.getName(), snapshotPath);
2083+
s_logger.debug(details);
2084+
return new Answer(cmd, false, details);
2085+
}
20792086
return new Answer(cmd, true, null);
20802087
} else if (dstore instanceof S3TO) {
20812088
final S3TO s3 = (S3TO)dstore;

0 commit comments

Comments
 (0)