diff --git a/beets/library.py b/beets/library.py index 85c6e1b40..ca3428683 100644 --- a/beets/library.py +++ b/beets/library.py @@ -61,9 +61,8 @@ class PathQuery(dbcore.FieldQuery): """ super(PathQuery, self).__init__(field, pattern, fast) - # By default, the case sensitivity depends on the platform. if case_sensitive is None: - case_sensitive = platform.system() != 'Windows' + case_sensitive = self.is_filesystem_case_sensitive() self.case_sensitive = case_sensitive # Use a normalized-case pattern for case-insensitive matches. @@ -75,6 +74,16 @@ class PathQuery(dbcore.FieldQuery): # As a directory (prefix). self.dir_path = util.bytestring_path(os.path.join(self.file_path, b'')) + @staticmethod + def is_filesystem_case_sensitive(): + library_path = beets.config['directory'].get() + if os.path.exists(library_path): + # Check if the path to the library exists in lower and upper case + return not (os.path.exists(library_path.lower()) and + os.path.exists(library_path.upper())) + # By default, the case sensitivity depends on the platform. + return platform.system() != 'Windows' + @classmethod def is_path_query(cls, query_part): """Try to guess whether a unicode query part is a path query. diff --git a/docs/changelog.rst b/docs/changelog.rst index 344702e34..a9e92709a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,6 +27,8 @@ Fixes: option. * The :ref:`list-cmd` command's help output now has a small query and format string example. Thanks to :user:`pkess`. :bug:`1582` +* The check whether the file system is case sensitive or not could lead to + wrong results. It is much more robust now. 1.3.14 (August 2, 2015)