2 Commits

Author SHA1 Message Date
dean
02954aa439 Merge branch 'develop' of https://kamco.git.gs.dabeeo.com/MVPTeam/kamco-train-api into develop 2026-04-09 09:34:47 +09:00
dean
e3cf7b8909 test 2026-04-09 09:34:26 +09:00

View File

@@ -622,6 +622,7 @@ public class FileManagerService {
final int[] fileCount = {0};
final int[] directoryCount = {0};
log.info("[StorageSpace] walkFileTree 시작 - path={}", directoryPath);
try {
Files.walkFileTree(
directory,
@@ -641,6 +642,12 @@ public class FileManagerService {
return FileVisitResult.CONTINUE;
}
});
log.info(
"[StorageSpace] walkFileTree 완료 - fileCount={}, dirCount={}, usedSize={} bytes ({})",
fileCount[0],
directoryCount[0],
usedSize[0],
formatFileSize(usedSize[0]));
} catch (IOException e) {
log.error("디렉토리 용량 계산 중 오류 발생: {}", directoryPath, e);
return FileManagerDto.StorageSpaceRes.builder()
@@ -659,7 +666,7 @@ public class FileManagerService {
.build();
}
// 디스크 공간 정보 조회 (FileStore 사용)
// 디스크 공간 정보 조회 (FileStore 사용) — basePath가 속한 파티션/NFS 마운트 전체 기준
long totalDiskSpace = 0;
long freeSpace = 0;
long usableSpace = 0;
@@ -667,17 +674,28 @@ public class FileManagerService {
try {
java.nio.file.FileStore fileStore = Files.getFileStore(directory);
totalDiskSpace = fileStore.getTotalSpace(); // 전체 디스크 용량
freeSpace = fileStore.getUnallocatedSpace(); // 남은 저장공간 (할당되지 않은 공간)
usableSpace = fileStore.getUsableSpace(); // 사용 가능한 공간 (실제 사용 가능)
totalDiskSpace = fileStore.getTotalSpace();
freeSpace = fileStore.getUnallocatedSpace(); // OS 미할당 공간 (root 예약 블록 포함 가능)
usableSpace = fileStore.getUsableSpace(); // 실제 프로세스가 사용 가능한 공간
log.info(
"[StorageSpace] FileStore - name={}, type={}, total={} bytes ({}), unallocated={} bytes ({}), usable={} bytes ({})",
fileStore.name(),
fileStore.type(),
totalDiskSpace,
formatFileSize(totalDiskSpace),
freeSpace,
formatFileSize(freeSpace),
usableSpace,
formatFileSize(usableSpace));
// 디스크 사용률 계산
// 사용률은 usableSpace 기준으로 계산 (더 정확한 실사용 가능 공간 반영)
if (totalDiskSpace > 0) {
long usedDiskSpace = totalDiskSpace - freeSpace;
long usedDiskSpace = totalDiskSpace - usableSpace;
usagePercentage = (usedDiskSpace * 100.0) / totalDiskSpace;
}
log.info("[StorageSpace] usagePercentage={}%", Math.round(usagePercentage * 100.0) / 100.0);
} catch (IOException e) {
log.debug("디스크 공간 정보 조회 중 오류 발생: {}", directoryPath, e);
log.warn("[StorageSpace] 디스크 공간 정보 조회 실패: {}", directoryPath, e);
// 디스크 정보 조회 실패 시에도 디렉토리 용량은 반환
}