Skip to content

Library totalSize overwritten when using search with libtype #695

Description

@JonnyWong16

Describe the issue
The library cached _total_size value is overwritten when using search with a different libtype than the main library type.

https://github.com/pkkid/python-plexapi/blob/4.4.1/plexapi/library.py#L380

This causes the totalSize property to return the cached value instead of the correct value.

https://github.com/pkkid/python-plexapi/blob/4.4.1/plexapi/library.py#L393

Code snipppets

>>> library = plex.library.section("TV Shows")
>>> print(library.totalSize)
2  # This is the number of TV Shows in the library
>>> library.searchEpisodes()  # This calls library.search(libtype='episode')
>>> print(library.totalSize)
51  # This is now the number of episodes in the library.

Expected behavior
Library totalSize should always be the number of items of the main library type (i.e. number of shows).

Enviroment (please complete the following information):

  • PlexAPI version: 4.4.1

Activity

  1. Hellowlol commented on Mar 15, 2021

    @Hellowlol
    Collaborator

    This isn't a bug it's intended... But the name is awful. I should have used different name as its pretty misleading. A better name would be total_view_size or something like that. This is used in the library.search to make search flexible and efficient. We should change it.

  2. self-assigned this
    on Mar 15, 2021
  3. JonnyWong16 commented on Mar 15, 2021

    @JonnyWong16
    CollaboratorAuthor

    totalSize should cache to _totalSize which is independant from fetchItems.

    Search should use a completely separate cached _totalViewSize which is used in fetchItems.

  4. added a commit that references this issue on Mar 15, 2021
    357818a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions