Fix: Create data directory before initializing search database
Ensures the data directory exists before attempting to open the SQLite database during Docker image build. This fixes SQLITE_CANTOPEN error during build-search-index. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const path = require('path');
|
||||
const fs = require('fs').promises;
|
||||
const fsSync = require('fs');
|
||||
|
||||
class SearchDatabase {
|
||||
constructor(dbPath) {
|
||||
@@ -10,6 +11,13 @@ class SearchDatabase {
|
||||
|
||||
// Initialize database connection
|
||||
async initialize() {
|
||||
// Ensure data directory exists
|
||||
const dataDir = path.dirname(this.dbPath);
|
||||
if (!fsSync.existsSync(dataDir)) {
|
||||
fsSync.mkdirSync(dataDir, { recursive: true });
|
||||
console.log('Created data directory:', dataDir);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db = new sqlite3.Database(this.dbPath, (err) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user