Fix database initialization - add directory creation for database file
This commit is contained in:
parent
c7cc1aca73
commit
ef35b5e8ef
@ -21,7 +21,20 @@ class DatabaseManager:
|
|||||||
self._init_database()
|
self._init_database()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Warning: Database initialization failed: {e}")
|
print(f"Warning: Database initialization failed: {e}")
|
||||||
# Continue with minimal functionality or raise the error
|
# Create the directory if it doesn't exist and the path has a directory component
|
||||||
|
import os
|
||||||
|
try:
|
||||||
|
# Check if path has a directory component
|
||||||
|
if os.path.dirname(self.config.path):
|
||||||
|
os.makedirs(os.path.dirname(self.config.path), exist_ok=True)
|
||||||
|
print(f"Created directory for database: {os.path.dirname(self.config.path)}")
|
||||||
|
else:
|
||||||
|
# If no directory, ensure current directory is writable
|
||||||
|
os.makedirs('.', exist_ok=True)
|
||||||
|
print("Verified current directory is writable")
|
||||||
|
except Exception as dir_error:
|
||||||
|
print(f"Warning: Could not create database directory: {dir_error}")
|
||||||
|
# Re-raise the original error
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _init_database(self):
|
def _init_database(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user