fix: ensure data directory exists before init_db call (#79)

sqlite3.connect() fails with 'unable to open database file' on fresh
installs where data/ directory does not exist. This happens with both
Docker (bind mount creates ./data as root, container user can't write)
and bare Python (no data/ directory at all).

Fix ensures data/ exists before any database operation:
- main.py: add os.makedirs before init_db() call
- start-librecrawl.sh: mkdir -p data at script start
- start-librecrawl.bat: mkdir data at script start

Fixes #65
This commit is contained in:
Abdul Aouwal authored and GitHub committed 2026-08-13 15:14:32 +10:00
1 parent d98ff55d84
commit 8f6dedb32d
3 files changed
+5

No files matched your search

+3
View File
@@ -54,6 +54,9 @@ if not os.environ.get('SECRET_KEY'):
# Enable compression for all responses
Compress(app)
# Ensure data directory exists before initializing the database
os.makedirs("data", exist_ok=True)
# Initialize database on startup
init_db()
+1
View File
@@ -1,5 +1,6 @@
@echo off
if not exist data mkdir data␍
echo Checking for Docker...
docker --version 2>nul
if errorlevel 1 goto nodocker
+1
View File
@@ -2,6 +2,7 @@
# Start LibreCrawl - tries Docker first, falls back to Python
mkdir -p data
echo "Checking for Docker..."
if command -v docker &> /dev/null && command -v docker compose &> /dev/null; then
echo "Docker found! Starting LibreCrawl with Docker..."