Skip to content

Duplicate files while scanning library #423

Closed

Description

@alexander-pecheny

While scanning my library in a symlinked folder cmus constantly finds duplicate files, like this:

Sometimes there are only two of them, other times three or even four (like in this example).

I probably do have some duplicate files, but it finds duplicates for practically every file, which is impossible — I have searched for many of supposedly duplicate files and found only one of each. I am unsure what info I should provide to clarify the issue :(, so please ask questions if you care to help.

Darwin Kernel Version 15.3.0, cmus v2.7.1

On the other note, how am I supposed to deal with duplicates anyway? I read the man, but couldn't find any way to display, e.g. the file path of the selected file (in pane 1). Duplicates make listening in album mode difficult. Have you considered providing the user with some option to deal with them, e.g. delete the duplicates, or add an additional level of grouping (e.g file path) that would remove the duplicates?

Activity

  1. z3t0 commented on Mar 31, 2016

    @z3t0

    You can delete individual songs with the "D" key

  2. z3t0 commented on Apr 1, 2016

    @z3t0

    It would be a good idea to add a feature where duplicate files are not added

  3. alexander-pecheny commented on Apr 1, 2016

    @alexander-pecheny
    Author

    @z3t0 Wouldn’t they be re-added if I add new music to library and then refresh cache?

    Anyway, looks like I found the original problem — symlinked folder was the culprit. If I added the folder by its real path, obsolete duplicates didn’t occur.

    Still unsure how to deal with legitimate duplicates though.

  4. flyingmutant commented on Apr 3, 2016

    @flyingmutant
    Member

    What do you mean by «legitimate duplicates»? Files with identical content, but different paths?

  5. alexander-pecheny commented on Apr 3, 2016

    @alexander-pecheny
    Author

    E.g. a band has a single and an album with the same name. They will be grouped together, which is not very convenient.

    I think that third level of grouping (by folder path) would solve this problem.

  6. jolange commented on Apr 4, 2016

    @jolange
    Contributor

    But that would impose a folder structure (Artist/Album/Track) which I think you should definitely not do.
    If there are different albums/singles named the same for one artist, then I think that's the actual problem. I personally would try to make this clear from the metadata and call them "Name" and "Name (Single)".

  7. alexander-pecheny commented on Apr 5, 2016

    @alexander-pecheny
    Author

    I do not think this approach imposes anything: the user is free to choose whatever folder structure suits him better. I propose that the path/folder structure be used only as a last means for disambiguation, in the cases where all metadata for files is identical. It is also convenient because file paths are already stored in the library, so you do not need to cache any more data.

    Before grouping by folder path, other levels of grouping may be added to solve the same problem, e.g musicbrainz ID. However, this approach has the aforementioned disadvantage of needing to cache more data.

  8. jolange commented on Apr 5, 2016

    @jolange
    Contributor

    Ok, but in my opinion "conditional disambiguation" is not desirable.
    Apart from that, using the location for distinction purposes goes a bit against the idea of a media library.

  9. alexander-pecheny commented on Apr 7, 2016

    @alexander-pecheny
    Author

    in my opinion "conditional disambiguation" is not desirable

    Could you please elaborate why? I am genuinely interested. I understand the controversial ideological grounds, but I can’t see any drawbacks from a UX perspective.

  10. jolange commented on Apr 7, 2016

    @jolange
    Contributor

    Well, thats a purley personal view, but I like to have one defined behaviour (yes, you could argue that this is still well-defined).
    I would certainly be at least surprised (if not confused) if suddenly there was a further grouping in one place that I don't see anywhere else.
    And again: I understand your point, but I think the disambiguation should explicitly happen in the album title (an attribute belonging to a media library item) rather than using file paths (which a library is trying to abstract from).

    Just my two cents.

  11. woffs commented on Nov 15, 2016

    @woffs

    I stumbled over the same problem. I have a directory tree with some duplicated (symlinked) content. For instance I have a subdir to be copied to a mobile MP3 player and another subdir with ripped CDs, and some of the content is in both subdirs, and it looks like the picture above. Would be nice if there was an option to squeeze the duplicated entries simply together somehow (if all metadata and filesize is identical and only the path is different). Otherwise I could try to reorganize my tree and make a cmus-subtree with no duplicated content. ;)

  12. mahkoh commented on Nov 15, 2016

    @mahkoh
    Member

    How do other players handle this?

  13. nefthy commented on Nov 15, 2016

    @nefthy
    Collaborator

    This can be fixed by calling realpath on the filename before processing. realpath will resolve symlinks and relative paths to a canonical absolute paths.

  14. 8 remaining items

  15. added a commit that references this issue on Feb 4, 2021
    eebc1ec
  16. added a commit that references this issue on Mar 5, 2021
    658c7a4
  17. rachmadaniHaryono commented on Dec 13, 2021

    @rachmadaniHaryono

    i have this issue and because there is no solution yet except #1052, i modify the cmus lib directly (~/.config/cmus.lib.pl)

    the drawback is i lose the playcount.

    currently there is no way to export play count as of 1 G

    Footnotes

    1. https://github.com/cmus/cmus/issues/489 ↩

  18. tehmasterer commented on Jan 9, 2023

    @tehmasterer

    Same issue here. I have a symlink in ~/Music that points to my network share that holds all my music. When adding the symlink, cmus created duplicates of all the files. I have a lot of music, and sorting through them to delete is not feasible.

  19. rachmadaniHaryono commented on Jan 10, 2023

    @rachmadaniHaryono

    i have to write my own python script to replace symlink

    for example /mnt/uuid/music/1.mp3 is equal to /home/username/music/1.mp3

    from pathlib import Path
    import difflib
    print_diff = True
    start_text = '/mnt/uuid'
    
    lib_path = Path('~/.config/cmus/lib.pl').expanduser()
    text = lib_path.read_text()
    lines = text.splitlines()
    good, bad = [], []
    for x in lines:
        (bad, good)[not x.startswith(start_text)].append(x)
    new_lines = list(
        sorted(
            set(
                good
                + [("/home/username" / Path(x).relative_to(start_text)).as_posix() for x in bad]
            )
        )
    )
    if print_diff:
        print('\n'.join(list(difflib.context_diff(lines, new_lines))))
    lib_path.write_text('\n'.join(new_lines))
  20. added a commit that references this issue on Jul 9, 2023
    f5c29a2
  21. added a commit that references this issue on Jul 13, 2023
    caa94b2
  22. added a commit that references this issue on Jul 13, 2023
    6167caa
  23. gavtroy commented on Aug 7, 2023

    @gavtroy
    Collaborator

    I've noticed a flaw in the ignore_duplicates option I added; that cmus won't catch duplicates if the original is currently hidden by a filter. They'll at least be stripped out of the library again if cmus is restarted with the filter disabled. Unfortunately I can't think of a good way to fix it right now, aside from something extremely invasive like gavtroy@filter-keeps-objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions