diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 0e484d8ce..bafd32ded 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -903,7 +903,9 @@ class Database: def _path_checker(self, path): newpath = os.path.dirname(path) if not os.path.isdir(newpath): - os.makedirs(newpath) + from beets.ui.commands import database_dir_creation + if database_dir_creation(newpath): + os.makedirs(newpath) def __init__(self, path, timeout=5.0): diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 3a3374013..bf2b184d2 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1398,6 +1398,12 @@ version_cmd = ui.Subcommand( version_cmd.func = show_version default_commands.append(version_cmd) +# database_location: return true if user wants to create the parent directories. +def database_dir_creation(path): + # Ask the user for a choice. + return ui.input_yn("{} does not exist, create it (Y/n)?" + .format(displayable_path(path))) + # modify: Declaratively change metadata.