khenriks / mp3fs

FUSE-based transcoding filesystem from FLAC to MP3
http://khenriks.github.io/mp3fs/
GNU General Public License v3.0
382 stars 46 forks source link

`file_type` is case-sensitive #54

Closed kylejohnson closed 4 years ago

kylejohnson commented 7 years ago

https://github.com/khenriks/mp3fs/blob/master/src/coders.cc#L73 calls file_type to determine if a file is a 'flac', however what it really is doing is checking the file extension.

In my case, I have many millions of flac files which have the extension .FLAC, which while they are valid flac files, mp3fs fails to transcode them as flac != FLAC.

root@colossus03:~# file flac/4058765179864_1_3.FLAC
flac/4058765179864_1_3.FLAC: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 15876646 samples

This is on Ubuntu 16.04.2 with a recent git clone of the mp3fs repo.

bak1an commented 7 years ago

Naive fix is there: https://github.com/khenriks/mp3fs/compare/master...bak1an:case-insensitive-naive

However, it won't work for all the possible cases like .fLaC, .OGG, etc; and the behaviour for cases when there is identically named files in the same directory with only difference in extension being uppercase will be rather random.

I would suggest adding another options flag that will change the way we're transforming filenames: instead of replacing file extension with target extension (.mp3) it would append it to original filename (and shadow origin file from being returned from readdir), so something.FLAC becomes something.FLAC.mp3 and something.fLaC becomes something.fLaC.mp3.

Decoder::CreateDecoder(...) will also downcase extension before comparing.

Does this sound sane?

khenriks commented 6 years ago

I think adding the options flag just like you described would make sense.