暂存提交
This commit is contained in:
@@ -35,12 +35,23 @@ public class LocalQualificationStorage {
|
||||
/** 服务启动时校验存储根目录,避免健康检查正常但首次上传才暴露挂载或权限问题。 */
|
||||
@PostConstruct
|
||||
public void initialize() {
|
||||
Path probe = null;
|
||||
try {
|
||||
Files.createDirectories(root);
|
||||
if (!Files.isDirectory(root) || !Files.isWritable(root)) {
|
||||
throw new IOException("存储根目录不可写");
|
||||
}
|
||||
probe = root.resolve(".qualification-storage-probe-" + UUID.randomUUID());
|
||||
Files.write(probe, new byte[] {0x42}, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
|
||||
Files.delete(probe);
|
||||
} catch (IOException exception) {
|
||||
if (probe != null) {
|
||||
try {
|
||||
Files.deleteIfExists(probe);
|
||||
} catch (IOException cleanupException) {
|
||||
exception.addSuppressed(cleanupException);
|
||||
}
|
||||
}
|
||||
LOGGER.error("企业资质存储根目录不可用:{}", root, exception);
|
||||
throw new IllegalStateException("企业资质存储根目录不可用", exception);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user