Refactor source directory handling in modelsProxyService.js
- Introduced a cached source directory variable to optimize the retrieval of model paths. - Updated comments for clarity on the source directory logic and its impact on cache validation.
This commit is contained in:
@@ -17,9 +17,15 @@ const PUBLIC_MODELS = path.join(PROJECT_ROOT, 'frontend', 'public', MODELS_REL);
|
||||
const CACHE_DIR = path.join(BACKEND_DIR, 'data', 'model-cache');
|
||||
const CLI_PATH = path.join(BACKEND_DIR, 'node_modules', '.bin', 'gltf-transform');
|
||||
|
||||
/** Production: frontend/dist; Local: frontend/public. Ermittelt bei Bedarf. */
|
||||
/** Einmal ermitteltes Quellverzeichnis (frontend/dist oder frontend/public). */
|
||||
let _sourceDir = null;
|
||||
|
||||
/** Production: frontend/dist; Local: frontend/public. Einmal pro Prozess festgelegt, damit
|
||||
* isCacheValid() stets gegen dieselbe Quelle prüft (kein Wechsel zwischen dist/public). */
|
||||
function getSourceDir() {
|
||||
return fs.existsSync(DIST_MODELS) ? DIST_MODELS : PUBLIC_MODELS;
|
||||
if (_sourceDir !== null) return _sourceDir;
|
||||
_sourceDir = fs.existsSync(DIST_MODELS) ? DIST_MODELS : PUBLIC_MODELS;
|
||||
return _sourceDir;
|
||||
}
|
||||
|
||||
/** Erlaubte Dateinamen (nur [a-z0-9_.-]+.glb) */
|
||||
|
||||
Reference in New Issue
Block a user