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

[core] Stop offline download at tile limit #4343

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Mar 16, 2016

The tile limit guard (when used) stops a download from continuing when the tile limit is reached. This wraps the guard in a method and employs it in both places currently necessary to ensure the guard has a chance to function.

cc @jfirebaugh @1ec5

@boundsj boundsj self-assigned this Mar 16, 2016
@boundsj boundsj added this to the ios-v3.2.0 milestone Mar 16, 2016
@@ -49,7 +49,8 @@ class OfflineDownload {
*/
void ensureResource(const Resource&, std::function<void (Response)> = {});
void ensureTiles(SourceType, uint16_t, const SourceInfo&);

bool hasExceededTileCount(const Resource& resource);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has side effects, but hasExceededTileCount sounds like the name of a pure function. How about checkTileCountLimit?

@jfirebaugh
Copy link
Contributor

Good catch! You're completely correct about the logic here. In addition to the code adjustment, we should add a regression test. Want to give that a shot?

@jfirebaugh
Copy link
Contributor

@boundsj The test and implementation changes look great. I checked them out locally and verified that the test fails before the change and passes after. 🚢

@boundsj
Copy link
Contributor Author

boundsj commented Mar 17, 2016

Thanks @jfirebaugh. Thanks for pointing out how the tests can hang, too. I made sure the new test will fail (and not hang in the run loop) if the required implementation is removed.

The tile limit guard (when used) stops a download from continuing
when the tile limit is reached. This wraps the guard in a method
and employs it in both places currently necessary to ensure the
guard has a chance to function. Tests have been updated to
ensure the fix works for a less trivial tile limit scenario.
@boundsj boundsj force-pushed the boundsj-stop-download-at-time-limit branch from be7bae0 to 0233b66 Compare March 17, 2016 21:23
@boundsj boundsj closed this Mar 17, 2016
@boundsj
Copy link
Contributor Author

boundsj commented Mar 17, 2016

Merged in bcb3bb0

@boundsj boundsj deleted the boundsj-stop-download-at-time-limit branch March 17, 2016 22:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants