Update src/pilgrim/utils/directory_manager.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Gustavo Henrique Miranda 2025-07-16 18:12:32 -03:00 committed by GitHub
parent a13c56a3a3
commit 4436d5e081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -45,11 +45,7 @@ class DirectoryManager:
Get the database file path following XDG Base Directory specification. Get the database file path following XDG Base Directory specification.
Creates the directory if it doesn't exist. Creates the directory if it doesn't exist.
""" """
pilgrim_dir = DirectoryManager.get_config_directory() pilgrim_dir = DirectoryManager.get_config_directory()
pilgrim_dir.mkdir(exist_ok=True)
# Database file path
db_path = pilgrim_dir / "database.db" db_path = pilgrim_dir / "database.db"
# If database doesn't exist in new location but exists in current directory, # If database doesn't exist in new location but exists in current directory,
@ -57,7 +53,11 @@ class DirectoryManager:
if not db_path.exists(): if not db_path.exists():
current_db = Path("database.db") current_db = Path("database.db")
if current_db.exists(): if current_db.exists():
shutil.copy2(current_db, db_path) try:
print(f"Database migrated from {current_db} to {db_path}") shutil.copy2(current_db, db_path)
# Consider using logging instead of print
print(f"Database migrated from {current_db} to {db_path}")
except (OSError, shutil.Error) as e:
raise RuntimeError(f"Failed to migrate database: {e}")
return db_path return db_path