Skip to content

listall() output is broken #64

@potors

Description

@potors

As the title says.

Let's say that you runned client.listall() and you have this folder structure:

Artist1
 └─ Album1
     └─ Single1
Artist2
 └─ Album2
     └─ Single2
Artist3
 └─ Album3
     ├─ Song1
     └─ Song2

When mpd's socket list they, it looks like this:

directory: Artist1;
directory: Artist1 / Album1;
file: Artist1 / Album1 / Single1;
directory: Artist2;
directory: Artist2 / Album2;
file: Artist2 / Album2 / Single2;
directory: Artist3;
directory: Artist3 / Album3;
file: Artist3 / Album3 / Song1;
file: Artist3 / Album3 / Song2;

As you call Client::listall, it does some parsing from that output.
But when you inspect the values, rust gives you this:

[
    Song {
        file: "Artist1/Album1/Single1",
        name: None,
        title: None,
        last_mod: None,
        artist: None,
        duration: None,
        place: None,
        range: None,
        tags: [
            ("directory", "Artist2"),
            ("directory", "Artist2/Album2")
        ],
    },
    Song {
        file: "Artist2/Album2/Single2",
        ...
        tags: [
            ("directory", "Artist3"),
            ("directory", "Artist3/Album3")
        ],
    },
    Song {
        file: "Artist3/Album3/Song1",
        ...
        tags: []
    },
    Song {
        file: "Artist3/Album3/Song2",
        ...
        tags: []
    }
]
  • Every field, except file, is missing
  • The tags are shifted up

I suppose that when parsing the output, it reads every row, then when it reaches a file label, read all to the next, and join everything together. Something like:

  • Discard: directory: Artist1
  • Discard: directory: Artist1/Album1
  • Take: file: Artist1/Album1/Single1
    • Tag: directory: Artist2
    • Tag: directory: Artist2/Album2
  • Take: file: Artist2/Album2/Single2
    • Tag: directory: Artist3
    • Tag: directory: Artist3/Album3
  • Take: file: Artist3/Album3/Song1
  • Take: file: Artist3/Album3/Song2

As shown above

  • Fields are missing, this part of the code is just... missing
  • Tags are shifted, and even if not, they are wrong (in sense that every other song from that album should have it)

Looks like this project is dead, I'm leaving.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions