Importing files via CLI doesn't escape special characters, causing glob to fail
Steps to reproduce
Describe the steps to reproduce the issue, like:
- Execute an import in a folder that contains special characters, such as
[
- Example:
python api/manage.py import_files --in-place --recursive --async $LIBRARY_ID '/path/to/files/[aaaa]my incredible music/*'
What happens?
No files are imported and the importer exits with an error.
What is expected?
Files should be properly imported.
Context
The reason lies in api/funkwhale_api/music/management/commands/import_files.py
, line 139 in my version (0.19.1). It goes like this:
for import_path in options["path"]:
matching += glob.glob(import_path, **glob_kwargs)
However glob
chokes on special characters and returns nothing. The glob docs indicate that you can use glob.escape
to escape these characters. In fact, adding glob.escape(import_path)
allows importing the files.
Funkwhale version(s) affected: 0.19.1