update 23

This commit is contained in:
2026-01-10 22:05:33 +09:00
parent a6a5a291ac
commit d0ba4161e5
7 changed files with 105 additions and 10 deletions

View File

@@ -0,0 +1,61 @@
package research.loghunter.config;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* 데이터베이스 및 앱 디렉토리 초기화 설정
*
* 앱 실행 시 필요한 디렉토리를 자동으로 생성합니다.
* - ~/.loghunter/data/ : SQLite DB 파일
* - ~/.loghunter/exports/ : 내보내기 파일
*/
@Slf4j
@Configuration
public class DatabaseConfig {
@Value("${app.base-path}")
private String basePath;
@Value("${app.export.path}")
private String exportPath;
@PostConstruct
public void init() {
try {
// 기본 디렉토리 생성
Path baseDir = Paths.get(basePath);
createDirectoryIfNotExists(baseDir);
// 데이터 디렉토리 생성
Path dataDir = baseDir.resolve("data");
createDirectoryIfNotExists(dataDir);
// 내보내기 디렉토리 생성
Path exportsDir = Paths.get(exportPath);
createDirectoryIfNotExists(exportsDir);
log.info("LogHunter 디렉토리 초기화 완료: {}", basePath);
log.info(" - 데이터: {}", dataDir);
log.info(" - 내보내기: {}", exportsDir);
} catch (IOException e) {
log.error("디렉토리 생성 실패: {}", e.getMessage());
throw new RuntimeException("LogHunter 디렉토리 초기화 실패", e);
}
}
private void createDirectoryIfNotExists(Path dir) throws IOException {
if (!Files.exists(dir)) {
Files.createDirectories(dir);
log.info("디렉토리 생성: {}", dir);
}
}
}

View File

@@ -6,7 +6,7 @@ spring:
name: log-hunter
datasource:
url: jdbc:sqlite:./data/loghunter.db
url: jdbc:sqlite:${user.home}/.loghunter/data/loghunter.db
driver-class-name: org.sqlite.JDBC
jpa:
@@ -28,7 +28,8 @@ spring:
# 앱 설정
app:
base-path: ${user.home}/.loghunter
crypto:
key: ${LOGHUNTER_CRYPTO_KEY:LogHunterDefaultKey32Bytes!!}
export:
path: ./exports
path: ${user.home}/.loghunter/exports