fix: cleanup directory if empty after removal of snapshot (#8002)

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
This commit is contained in:
Vishesh 2023-09-29 18:51:53 +05:30 committed by GitHub
parent 221f863939
commit f2c1775657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;