geigerzaehler / beets-alternatives

Beets plugin to manage external files
MIT License
91 stars 21 forks source link

beet alt update doesn't always remove obsolete links #47

Closed dosoe closed 4 years ago

dosoe commented 4 years ago

Hi! I've been using beets_alternatives to create softlinks and therefore have two parralel classification systems for my music. However, I noticed a problem: When the directory of a file changes and I apply beet alt update by-work it creates new links with updated paths and targets, but doesn't remove the old ones. Here my configuration:

alternatives:
    by-work:
        directory: /media/soergeld/My Passport/by-work
        paths:
            comp type::'non-classical': Non-Classique/$aaa/$aa/$tr
            type::'non-classical': Non-Classique/$aaa/$aa/$tr
            comp type::'medieval': Medieval/$aaa/$aa/$tr
            type::'medieval': Medieval/$aaa/$aa/$tr
            comp pw::'No_Work': Classique/$artist_sort/Divers/$aaa/$aa/$tr
            pw::'No_Work': Classique/$artist_sort/Divers/$aaa/$aa/$tr
            comp pc::'No_Parent_Composer': Classique/$artist_sort/$pw/$aaa/$aa/$tr
            pc::'No_Parent_Composer': Classique/$artist_sort/$pw/$aaa/$aa/$tr
            comp work_prefix::'None':  Classique/$pc/$pw/$aaa/$aa/$tr
            work_prefix::'None':  Classique/$pc/$pw/$aaa/$aa/$tr
            comp: Classique/$pc/$work_prefix/$pw/$aaa/$aa/$tr
            default: Classique/$pc/$work_prefix/$pw/$aaa/$aa/$tr

        formats: link

tr, pw, pc, aa, aaa and type are created using the inline plugin, I can show you how if needed.

As an example, beet mbsync && beet write outputted, among other things,

Georg Philipp Telemann - Complete Overtures, Volume 1 - Overture in D TWV 55: D18, 1. Ouverture
  albumartist: Georg Philipp Telemann; Collegium Instrumentale Brugense, Patrick Peire -> Georg Philipp Telemann; Het Kamerokest, Patrick Peire
  albumartist_sort: Telemann, Georg Philipp; Collegium Instrumentale Brugense, Peire, Patrick -> Telemann, Georg Philipp; Kamerokest, Het, Peire, Patrick
.
.
.
Georg Philipp Telemann - Complete Overtures, Volume 1 - Overture in A TWV 55: A4, 4. Minuetta 1-Minuetta 2
  albumartist: Georg Philipp Telemann; Collegium Instrumentale Brugense, Patrick Peire -> Georg Philipp Telemann; Het Kamerokest, Patrick Peire
  albumartist_sort: Telemann, Georg Philipp; Collegium Instrumentale Brugense, Peire, Patrick -> Telemann, Georg Philipp; Kamerokest, Het, Peire, Patrick

The files then got moved according to their new metadata. Applying beet alt update by-work after that showed

+/media/soergeld/My Passport/by-work/Classique/Telemann, Georg Philipp/Overture-Suite in D, TWV 55_D18/Kamerokest, Het, Peire, Patrick/Complete Overtures, Volume 1/1-1 Overture in D TWV 55_ D18, 1. Ouverture.mp3
.
.
.
+/media/soergeld/My Passport/by-work/Classique/Telemann, Georg Philipp/Overture in A, TWV 55_A4/Kamerokest, Het, Peire, Patrick/Complete Overtures, Volume 1/3-73 Overture in A TWV 55_ A4, 4. Minuetta 1-Minuetta 2.mp3

but the old links remain. Do you have an idea why? I didn't notice this behaviour before and it seemed to work fine, but then I didn't check in detail as I have a collection of ~50 000 tracks. However, find /media/soergeld/My\ Passport/by-work/ -xtype l shows more broken links, and I noticed that I had to remove all links and restart from scratch (which isn't that much of a problem) from time to time. It seems like at least sometimes, more precisely when you move a file with beets, beets-alternatives would create new links and not redirect (and eventually modify) the existing ones, that are then left broken.

So to summarize: I have files on beets with soft links from beets-alternatives I change the files on beets and move them I want to update the soft links Instead of updating the old soft links to the new location of the files, new soft links are created and the old ones are left broken.

wisp3rwind commented 4 years ago

Thanks for the report & sorry for the belated reply @dosoe! I believe I've pinned down the issue, will attempt a fix now.

dosoe commented 4 years ago

Thanks a lot! No problem, I guess right now everyone has other things to worry about.

wisp3rwind commented 4 years ago

@dosoe: The linked PR should fix this issue, if it's not too much of a hassle for you to test it before merging, that'd be perfect!