Skip to content

Commit 39632b3

Browse files
committed
Merge pull request #145 from longbai/progress_not_back
进度不回退
2 parents e116926 + a974117 commit 39632b3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

QiniuSDK/Storage/QNFormUpload.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ @interface QNFormUpload ()
2626
@property (nonatomic, strong) QNUploadOption *option;
2727
@property (nonatomic, strong) QNUpCompletionHandler complete;
2828
@property (nonatomic, strong) QNConfiguration *config;
29+
@property (nonatomic) float previousPercent;
2930

3031
@end
3132

@@ -46,6 +47,7 @@ - (instancetype)initWithData:(NSData *)data
4647
_complete = block;
4748
_httpManager = http;
4849
_config = config;
50+
_previousPercent = 0;
4951
}
5052
return self;
5153
}
@@ -72,6 +74,11 @@ - (void)put {
7274
if (percent > 0.95) {
7375
percent = 0.95;
7476
}
77+
if (percent > _previousPercent) {
78+
_previousPercent = percent;
79+
} else {
80+
percent = _previousPercent;
81+
}
7582
_option.progressHandler(_key, percent);
7683
};
7784

QiniuSDK/Storage/QNResumeUpload.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ @interface QNResumeUpload ()
4242

4343
@property (nonatomic, strong) NSArray *fileAry;
4444

45+
@property (nonatomic) float previousPercent;
46+
4547
- (void)makeBlock:(NSString *)uphost
4648
offset:(UInt32)offset
4749
blockSize:(UInt32)blockSize
@@ -89,6 +91,7 @@ - (instancetype)initWithFile:(id<QNFileDelegate>)file
8991
_config = config;
9092

9193
_token = token;
94+
_previousPercent = 0;
9295
}
9396
return self;
9497
}
@@ -197,6 +200,11 @@ - (void)nextTask:(UInt32)offset retriedTimes:(int)retried host:(NSString *)host
197200
if (percent > 0.95) {
198201
percent = 0.95;
199202
}
203+
if (percent > _previousPercent) {
204+
_previousPercent = percent;
205+
} else {
206+
percent = _previousPercent;
207+
}
200208
self.option.progressHandler(self.key, percent);
201209
};
202210

0 commit comments

Comments
 (0)