Skip to content

Commit ab024e2

Browse files
authored
Merge pull request #386 from YangSen-qn/network_status_check
Network status check & optimize upload progress & optimize some concurrent logic
2 parents 9e8157a + 19cf5f1 commit ab024e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+870
-290
lines changed

.github/workflows/ci-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828
env:
2929
QINIU_TEST_ENV: travis
3030
run: |
31-
xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_iOS -configuration Debug -destination 'platform=iOS Simulator,OS=14.2,name=iPhone 8 Plus' -enableCodeCoverage YES
31+
xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_iOS -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 8 Plus' -enableCodeCoverage YES
3232
xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_Mac -configuration Debug -destination 'platform=macOS,arch=x86_64'
3333
bash <(curl -s https://codecov.io/bash)

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#Changelog
2+
## 8.2.0(2021-02-20)
3+
## 增加
4+
- 增加网络监控功能,选择最优Host进行上传
5+
- 处理上传进度不准确问题
6+
- 优化日志统计
7+
28
## 8.1.2(2021-01-18)
39
## 增加
410
- 区域查询采用SingleFlight模式

Qiniu.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Qiniu'
3-
s.version = '8.1.2'
3+
s.version = '8.2.0'
44
s.summary = 'Qiniu Resource Storage SDK for iOS and Mac'
55
s.homepage = 'https://github.com/qiniu/objc-sdk'
66
s.social_media_url = 'http://weibo.com/qiniutek'

QiniuDemo/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source 'https://github.com/CocoaPods/Specs.git'
33
target "QiniuDemo" do
44
platform :ios, "7.0"
55

6-
# pod 'Qiniu'
6+
# pod 'Qiniu', '~> 8.1.1'
77
pod 'Qiniu',:path => '../'
88
end
99

QiniuDemo/QiniuDemo/ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ - (IBAction)uploadAction:(UIButton *)sender {
4848
if (self.uploadState == UploadStatePrepare) {
4949

5050
#ifdef YourToken
51-
// NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource.dmg" ofType:nil];
52-
NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource_49M.zip" ofType:nil];
51+
NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource.dmg" ofType:nil];
52+
// NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource_49M.zip" ofType:nil];
5353
[self uploadImageToQNFilePath:path];
5454
[self changeUploadState:UploadStateUploading];
5555
#else

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 62 additions & 0 deletions
Large diffs are not rendered by default.

QiniuSDK/Collect/QNReportItem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern NSString *const QNReportRequestKeyUpTime;
5656
extern NSString *const QNReportRequestKeyStatusCode;
5757
extern NSString *const QNReportRequestKeyRequestId;
5858
extern NSString *const QNReportRequestKeyHost;
59+
extern NSString *const QNReportRequestKeyHttpVersion;
5960
extern NSString *const QNReportRequestKeyRemoteIp;
6061
extern NSString *const QNReportRequestKeyPort;
6162
extern NSString *const QNReportRequestKeyTargetBucket;
@@ -88,6 +89,7 @@ extern NSString *const QNReportRequestKeySignalStrength;
8889
extern NSString *const QNReportRequestKeyPrefetchedDnsSource;
8990
extern NSString *const QNReportRequestKeyPrefetchedBefore;
9091
extern NSString *const QNReportRequestKeyPrefetchedErrorMessage;
92+
extern NSString *const QNReportRequestKeyNetworkMeasuring;
9193

9294

9395
//MARK:-- 分块上传统计⽇志

QiniuSDK/Collect/QNReportItem.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ - (NSString *)qualityResult{
171171
NSString * const QNReportRequestKeyStatusCode = @"status_code";
172172
NSString * const QNReportRequestKeyRequestId = @"req_id";
173173
NSString * const QNReportRequestKeyHost = @"host";
174+
NSString * const QNReportRequestKeyHttpVersion = @"http_version";
174175
NSString * const QNReportRequestKeyRemoteIp = @"remote_ip";
175176
NSString * const QNReportRequestKeyPort = @"port";
176177
NSString * const QNReportRequestKeyTargetBucket = @"target_bucket";
@@ -203,6 +204,7 @@ - (NSString *)qualityResult{
203204
NSString * const QNReportRequestKeyPrefetchedDnsSource = @"prefetched_dns_source";
204205
NSString * const QNReportRequestKeyPrefetchedBefore = @"prefetched_before";
205206
NSString * const QNReportRequestKeyPrefetchedErrorMessage = @"prefetched_error_message";
207+
NSString * const QNReportRequestKeyNetworkMeasuring = @"network_measuring";
206208

207209
//MARK:-- 分块上传统计⽇志
208210
NSString * const QNReportBlockKeyLogType = @"log_type";

QiniuSDK/Common/QNAutoZone.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ - (instancetype)init{
110110

111111
- (QNZonesInfo *)getZonesInfoWithToken:(QNUpToken *)token {
112112
if (token == nil) return nil;
113-
[_lock lock];
113+
[self.lock lock];
114114
QNZonesInfo *zonesInfo = [_cache objectForKey:[token index]];
115-
[_lock unlock];
115+
[self.lock unlock];
116116
return zonesInfo;
117117
}
118118

@@ -161,7 +161,7 @@ - (void)preQuery:(QNUpToken *)token
161161
value.response = response;
162162
value.metrics = metrics;
163163
complete(value, nil);
164-
164+
165165
[self destroyUploadRequestTransaction:transaction];
166166
}];
167167

@@ -198,13 +198,17 @@ - (QNRequestTransaction *)createUploadRequestTransaction:(QNUpToken *)token{
198198
QNRequestTransaction *transaction = [[QNRequestTransaction alloc] initWithHosts:@[kQNPreQueryHost00, kQNPreQueryHost01]
199199
regionId:QNZoneInfoEmptyRegionId
200200
token:token];
201+
[self.lock lock];
201202
[self.transactions addObject:transaction];
203+
[self.lock unlock];
202204
return transaction;
203205
}
204206

205207
- (void)destroyUploadRequestTransaction:(QNRequestTransaction *)transaction{
206208
if (transaction) {
209+
[self.lock lock];
207210
[self.transactions removeObject:transaction];
211+
[self.lock unlock];
208212
}
209213
}
210214

QiniuSDK/Common/QNZoneInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern NSString *const QNZoneInfoEmptyRegionId;
1616
@interface QNZoneInfo : NSObject
1717

1818
@property(nonatomic, assign, readonly)long ttl;
19+
@property(nonatomic, assign, readonly)BOOL http3Enabled;
1920
@property(nonatomic, strong, readonly)NSArray<NSString *> *domains;
2021
@property(nonatomic, strong, readonly)NSArray<NSString *> *old_domains;
2122

0 commit comments

Comments
 (0)