fix: geoMatch loadFrames crash when GEO_DATA_DIR missing on new server

- Add fs.existsSync check before readdirSync in loadFrames()
- Add warning logs when GEO_DATA_DIR, drone CSV, or building/ dir not found
- Remove dead csvPath variable (unused)
- Add warning log in loadPois() when building/ dir missing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
minsung
2026-04-02 17:17:59 +09:00
parent 958ea3f75a
commit c1b6f99032
2 changed files with 65 additions and 5 deletions

View File

@@ -276,15 +276,19 @@ function loadFrames(): DroneFrame[] {
if (_frames) return _frames;
if (!_dataDir) return [];
const csvPath = fs.readdirSync(_dataDir)
.find(f => f.endsWith('.csv') && !fs.statSync(path.join(_dataDir!, f)).isDirectory()
&& !path.join(_dataDir!, f).includes('building'));
if (!fs.existsSync(_dataDir)) {
console.warn(`[geo] GEO_DATA_DIR not found: ${_dataDir}. Set GEO_DATA_DIR env var.`);
return [];
}
// 드론 CSV는 data dir 바로 아래 (building 폴더 제외)
const files = fs.readdirSync(_dataDir).filter(f =>
f.endsWith('.csv') && f.includes('회덕') && !f.includes('POI') && !f.includes('측점')
);
if (!files.length) return [];
if (!files.length) {
console.warn(`[geo] No drone CSV (containing '회덕') found in: ${_dataDir}`);
return [];
}
const rows = readCsvUtf8(path.join(_dataDir, files[0]));
const header = rows[0].map(h => h.trim().replace(/^\uFEFF/, ''));
@@ -309,7 +313,10 @@ function loadPois(): GeoPoint[] {
if (!_dataDir) return [];
const buildingDir = path.join(_dataDir, 'building');
if (!fs.existsSync(buildingDir)) return [];
if (!fs.existsSync(buildingDir)) {
console.warn(`[geo] building/ dir not found: ${buildingDir}`);
return [];
}
const result: GeoPoint[] = [];