Skip to content

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

Open
aouwalitshikkha wants to merge 1 commit into
PhialsBasement:mainfrom
aouwalitshikkha:fix/65-data-directory-crash
Open

fix: ensure data directory exists before init_db call (#65)#79
aouwalitshikkha wants to merge 1 commit into
PhialsBasement:mainfrom
aouwalitshikkha:fix/65-data-directory-crash

Conversation

@aouwalitshikkha

Copy link
Copy Markdown

Problem

sqlite3.connect() fails with unable to open database file on fresh installs where the 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).

Reported in #65.

Fix

3 files changed, 5 insertions added — ensures data/ exists before any database operation:

File Change
main.py os.makedirs("data", exist_ok=True) before init_db() call
start-librecrawl.sh mkdir -p data at script start
start-librecrawl.bat if not exist data mkdir data at script start

os.makedirs() was already present inside src/auth_db.py's init_db(), but the directory must exist before init_db() is reached. The startup scripts additionally ensure Docker bind mounts a pre-created directory with correct host-side permissions.

Validation

  • git diff --stat: 3 files, 5 insertions, 0 deletions
  • Clean targeted changes, no whitespace or line-ending noise

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 PhialsBasement#65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant