diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index 05862287..a9f083d5 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -228,16 +228,16 @@ class Song: if directories is None: directories = self.config['datadir'] - for directory in directories: - for extension in extensions: - if os.path.isfile(os.path.join(directory, filename + extension)): - return directory, filename, extension - songdir = os.path.dirname(self.fullpath) for extension in extensions: if os.path.isfile(os.path.join(songdir, filename + extension)): return "", os.path.join(songdir, filename), extension + for directory in directories: + for extension in extensions: + if os.path.isfile(os.path.join(directory, filename + extension)): + return directory, filename, extension + raise FileNotFoundError(filename) def search_file(self, filename, extensions=None, *, datadirs=None):