Skip to content

Improve error message for unwritable database directoryBetter sqlite error #5731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

CarolineKevnick
Copy link

This PR improves the SQLite error message shown when the database file cannot be opened due to permissions issues.

It detects sqlite3.OperationalError messages related to "unable to open database file" and gives the user a more helpful explanation:

  • Suggests checking that the directory exists
  • Explains that the directory must be writable

Fixes #1676

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@snejus snejus requested a review from Copilot April 20, 2025 14:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR primarily improves the error message shown when SQLite is unable to open the database file due to permission issues. In addition, it refactors several modules for formatting consistency and more concise code style.

  • Improved the SQLite error message in the database module.
  • Reformatted multi-line calls and conditional statements across modules.
  • Enhanced consistency in code style across error handling, logging, and helper functions.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
beets/util/pipeline.py Reformatted thread initialization for a cleaner single-line call.
beets/util/m3u.py Simplified error raising with FilesystemError by removing redundant newlines.
beets/util/functemplate.py Changed multi-line list comprehensions into a single-line format for consistency.
beets/util/bluelet.py Condensed nested if conditions into single-line expressions without altering logic.
beets/util/artresizer.py Removed extra indentation in function definitions and log messages to improve readability.
beets/util/init.py Adjusted formatting in logging and path handling methods for uniformity.
beets/ui/commands.py Streamlined function parameter formatting and string concatenation in logging statements.
beets/ui/init.py Improved code consistency by reformatting loops and inline expressions.
beets/random.py Converted multi-line function signature to a single-line style.
beets/plugins.py Reformatted list comprehensions and generator expressions for clarity.
beets/library.py Added an extra query for the art field and simplified conditionals without logic change.
beets/importer.py Refactored album art detection and streamlined code formatting for clarity.
beets/dbcore/queryparse.py Simplified inline constructions in iterators for improved readability.
beets/dbcore/query.py Adjusted string replacements to a single-line style while maintaining functionality.
beets/dbcore/db.py Enhanced the sqlite3.OperationalError message to guide users to check directory existence/permissions.
beets/autotag/mb.py Converted multi-line tuple unpacking to a more concise single-line format.
beets/autotag/match.py Reformatted comprehensions and conditional expressions to improve code clarity.
beets/autotag/hooks.py Simplified yield-from calls by compacting multi-line expressions.
beets/autotag/init.py Streamlined metadata assignment with reduced nesting in tuple unpacking.
beets/art.py Modernized the call to the ArtResizer and adjusted embedding/logging for consistency.

@snejus
Copy link
Member

snejus commented Apr 20, 2025

Thanks for your contribution!

@wisp3rwind comment under #5730 applies here too:

Please read & follow our development guide at https://github.com/beetbox/beets/blob/master/CONTRIBUTING.rst, this PR messes up our code style in many (also unrelated) files, making it impossible to review. Eventually, this should also have tests, but it might make sense to first discuss here whether the code seems like a sensible approach to the problem.

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.

Better error message when directory containing database file is not writeable
2 participants