Merge release branch 4.18 to main

* 4.18:
  fix: cleanup directory if empty after removal of snapshot (#8002)
This commit is contained in:
Daan Hoogland 2023-09-29 16:18:16 +02:00
commit f70b42a018

View File

@ -2076,6 +2076,13 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
s_logger.warn(details); s_logger.warn(details);
return new Answer(cmd, false, 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); return new Answer(cmd, true, null);
} else if (dstore instanceof S3TO) { } else if (dstore instanceof S3TO) {
final S3TO s3 = (S3TO)dstore; final S3TO s3 = (S3TO)dstore;