[ios, macos] Offline storage size API
Added a property to MGLOfflineStorage that indicates the disk space occupied by all cached and offline resources. Fixes #5580.
This commit is contained in:
committed by
Minh Nguyễn
parent
d9aa812c47
commit
1bc4f0e027
@@ -217,6 +217,14 @@ typedef void (^MGLOfflinePackRemovalCompletionHandler)(NSError * _Nullable error
|
||||
*/
|
||||
- (void)setMaximumAllowedMapboxTiles:(uint64_t)maximumCount;
|
||||
|
||||
/**
|
||||
The cumulative size, measured in bytes, of all downloaded resources on disk.
|
||||
|
||||
The returned value includes all resources, including tiles, whether downloaded
|
||||
as part of an offline pack or due to caching during normal use of `MGLMapView`.
|
||||
*/
|
||||
@property (nonatomic, readonly) unsigned long long countOfBytesCompleted;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -275,6 +275,19 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = @"MaximumCount";
|
||||
_mbglFileSource->setOfflineMapboxTileCountLimit(maximumCount);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (unsigned long long)countOfBytesCompleted {
|
||||
NSURL *cacheURL = [[self class] cacheURLIncludingSubdirectory:YES];
|
||||
NSString *cachePath = cacheURL.path;
|
||||
if (!cachePath) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:cachePath error:NULL];
|
||||
return attributes.fileSize;
|
||||
}
|
||||
|
||||
#pragma mark MGLOfflinePackDelegate methods
|
||||
|
||||
- (void)offlinePack:(MGLOfflinePack *)pack progressDidChange:(__unused MGLOfflinePackProgress)progress {
|
||||
|
||||
@@ -144,4 +144,8 @@
|
||||
XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks - 1, @"Removed pack should have been removed from the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks or -testAddPack.");
|
||||
}
|
||||
|
||||
- (void)testCountOfBytesCompleted {
|
||||
XCTAssertGreaterThan([MGLOfflineStorage sharedOfflineStorage].countOfBytesCompleted, 0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON
|
||||
* As the user zooms in, tiles from lower zoom levels are scaled up until tiles for higher zoom levels are loaded. ([#5143](https://github.com/mapbox/mapbox-gl-native/pull/5143))
|
||||
* Added [quadkey](https://msdn.microsoft.com/en-us/library/bb259689.aspx) support and limited WMS support in raster tile URL templates. ([#5628](https://github.com/mapbox/mapbox-gl-native/pull/5628))
|
||||
* Fixed an issue causing polyline and polygon annotations to disappear when the zoom level is one less than the maximum zoom level. ([#5418](https://github.com/mapbox/mapbox-gl-native/pull/5418))
|
||||
* Added a property to MGLOfflineStorage, `countOfBytesCompleted`, that indicates the disk space occupied by all cached and offline resources. ([#5585](https://github.com/mapbox/mapbox-gl-native/pull/5585))
|
||||
* The `text-pitch-alignment` property is now supported in stylesheets for improved street label legibility on a tilted map. ([#5288](https://github.com/mapbox/mapbox-gl-native/pull/5288))
|
||||
* The `icon-text-fit` and `icon-text-fit-padding` properties are now supported in stylesheets, allowing the background of a shield to automatically resize to fit the shield’s text. ([#5334](https://github.com/mapbox/mapbox-gl-native/pull/5334))
|
||||
* Improved the performance of relocating a non-view-backed point annotation by changing its `coordinate` property. ([#5385](https://github.com/mapbox/mapbox-gl-native/pull/5385))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* As the user zooms in, tiles from lower zoom levels are scaled up until tiles for higher zoom levels are loaded. ([#5143](https://github.com/mapbox/mapbox-gl-native/pull/5143))
|
||||
* Added [quadkey](https://msdn.microsoft.com/en-us/library/bb259689.aspx) support and limited WMS support in raster tile URL templates. ([#5628](https://github.com/mapbox/mapbox-gl-native/pull/5628))
|
||||
* Fixed an issue causing polyline and polygon annotations to disappear when the zoom level is one less than the maximum zoom level. ([#5418](https://github.com/mapbox/mapbox-gl-native/pull/5418))
|
||||
* Added a property to MGLOfflineStorage, `countOfBytesCompleted`, that indicates the disk space occupied by all cached and offline resources. ([#5585](https://github.com/mapbox/mapbox-gl-native/pull/5585))
|
||||
* The `text-pitch-alignment` property is now supported in stylesheets for improved street label legibility on a tilted map. ([#5288](https://github.com/mapbox/mapbox-gl-native/pull/5288))
|
||||
* The `icon-text-fit` and `icon-text-fit-padding` properties are now supported in stylesheets, allowing the background of a shield to automatically resize to fit the shield’s text. ([#5334](https://github.com/mapbox/mapbox-gl-native/pull/5334))
|
||||
* Improved the performance of relocating a point annotation by changing its `coordinate` property. ([#5385](https://github.com/mapbox/mapbox-gl-native/pull/5385))
|
||||
|
||||
Reference in New Issue
Block a user