beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.84k stars 1.82k forks source link

On case-insensitive filesystems, check for re-imports more robustly to avoid duplicate database entries #1704

Open m0nkey-br4in opened 8 years ago

m0nkey-br4in commented 8 years ago

I use beets and iTunes on Windows. iTunes "manages the library" and beets updates tags in files. My library is mostly tagged with Picard, so I've disabled autotag. The workflow looks like this:

Now I have only one file, and two tracks with two paths, both of which beets can successfully resolve to that file, so beet update doesn't help.

Could have been worse: the first time I reimported everything I typed in the directory name as \music\ instead of \Music\, so I ended up with an entire library duplicated. Had to delete it and restart from scratch.

sampsyo commented 8 years ago

Hmm; sounds frustrating.

Do you have any thoughts about what we should change, specifically? For example, should update scan for case changes and update the database? Should beets check for the true case every time it tries to read a file? (That last option sounds too expensive.)

m0nkey-br4in commented 8 years ago

I still have a very vague idea of how exactly this needs to be implemented. As I understand it, there is only one way new paths can enter the database: via import. So I'd start with comparing incoming paths with paths already in the db in a system-appropriate way. And then I'd need a way to retroactively merge duplicate paths already in the db. Like, update would query the filesystem for the "canonical" name of a file and merge and update records. Or something like that.

pkess commented 8 years ago

Hey,

i tried to reproduce this and work on a solution, but i can't. Im doing following:

  1. import some albums to an empty beet db
  2. rename the files in beets library folder with case change
  3. run beet import on the library folder

I'm getting a hint that the albums alreydy exists and everything is fine for me

m0nkey-br4in commented 8 years ago

You have to disable autotag, or it masks the issue. And I hope you're trying this on Windows On 2 Dec 2015 23:08, "Peter Kessen" notifications@github.com wrote:

Hey,

i tried to reproduce this and work on a solution, but i can't. Im doing following:

  1. import some albums to an empty beet db
  2. rename the files in beets library folder with case change
  3. run beet import on the library folder

I'm getting a hint that the albums alreydy exists and everything is fine for me

— Reply to this email directly or view it on GitHub https://github.com/sampsyo/beets/issues/1704#issuecomment-161418120.

pkess commented 8 years ago

ok, after disabling autotag and also copy on import i can reproduce this now. I would suggest to implement a check at the import action. Beets should check if the item is already exists in library.

I'm working on that

sampsyo commented 8 years ago

Coming back to this ticket, it seem like at least one reasonable course of action would be to, in the importer's re-import checker, compare in a case-insensitive way on case-insensitive filesystems. How to do this efficiently, however, is still an open question.