Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Add convenience methods for getting the storage size of existing offline resources #5580

Closed

Description

@friedbunny

We should provide convenience methods for getting the total stored size of offline resources — both for individual offline regions and the aggregate.

As of iOS v3.3.0, to calculate the total size of all available offline resources, you would:

  1. Wait for MGLOfflineStorage.sharedOfflineStorage().packs to populate by watching this property via KVO.
  2. Get an array of all existing packs via the above packs property.
  3. Request the progress for each item in that array via -[MGLOfflinePack requestProgress:].
  4. Wait for each pack to return a value, either via KVO on its MGLOfflinePack.progress or by listening for MGLOfflinePackProgressChangedNotification notifications.
  5. Total all of the packs’ MGLOfflinePackProgress.countOfBytesCompleted values.

/cc @1ec5 @jfirebaugh @zugaldia

Activity

  1. added
    iOS
    Android
    on Jul 5, 2016
  2. jfirebaugh commented on Jul 5, 2016

    @jfirebaugh
    Contributor

    That algorithm would double count resources that were shared by two packs. I agree there should be a method for getting aggregate statistics.

    I'm not sure what you mean by "individual offline regions" -- this API already exists, and is likely as convenient as possible given the asynchronous nature of offline. Note that any aggregate statistic API would also be asynchronous.

  3. 1ec5 commented on Jul 5, 2016

    @1ec5
    Contributor

    We could implement this API at the SDK level, more or less, by returning the file size of cache.db, which we already know the location of. It’d include any space taken up by ambient caching (which can overlap with offline packs).

  4. friedbunny commented on Jul 5, 2016

    @friedbunny
    ContributorAuthor

    "individual offline regions" -- this API already exists

    Right, that’s essentially the singular version of steps 1 through 4. It may not be that the underlying API can be improved, but it would be nice if we could abstract the multilayered KVO grunt work — perhaps by providing completion blocks on the async methods.

  5. 1ec5 commented on Jul 6, 2016

    @1ec5
    Contributor

    #5585 implements the synchronous API proposed in #5580 (comment) on iOS and macOS. Even if the cache’s file size differs from the size you’d get by enumerating the offline packs’ statuses, I think the former is what a developer would generally be interested in anyways.

  6. jfirebaugh commented on Jul 6, 2016

    @jfirebaugh
    Contributor

    I think we should hold out for a database-query based API, which would provide resource and tile counts in addition to total size, which people have been asking for.

  7. 1ec5 commented on Jul 6, 2016

    @1ec5
    Contributor

    A more granular API for resource and tile counts would certainly be desirable. However, I think the API added in #5585 is valuable on its own, not least because it’s synchronous.

  8. added a commit that references this issue on Jul 10, 2016
    3fb5a5d
  9. added a commit that references this issue on Jul 19, 2016
    1bc4f0e
  10. added a commit that references this issue on Jul 19, 2016
    e421180
  11. added
    Android
    iOS
    and removed
    Android
    iOS
    on Jul 19, 2016
  12. 1ec5 commented on Jul 19, 2016

    @1ec5
    Contributor

    Leaving this ticket open for both platforms in light of #5580 (comment).

  13. reopened this on Jul 19, 2016
  14. removed
    iOS
    on Nov 9, 2016
  15. 1ec5 commented on Sep 27, 2017

    @1ec5
    Contributor

    We left this issue open for #5580 (comment), but I think #9460 better covers that feature now.

  16. jfirebaugh commented on Sep 27, 2017

    @jfirebaugh
    Contributor

    If we're going to conflate this with #9460, we should at least do some issue retitling and / or description editing. The way they are currently described, they are distinct: this issue is about getting the total size (in bytes) of all resources in an offline region (or potentially broken down by resource type). #9460 is about getting the total number of tiles for a region (and for the use case described there, preferably before committing to downloading those tiles).

  17. added
    archived
    on Nov 4, 2018
  18. stale commented on Dec 2, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Androidarchivedoffline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions