Skip to content

Commit 3a60bfa

Browse files
committed
optimize phassert
1 parent 53075ed commit 3a60bfa

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#Changelog
2+
## 8.3.1(2021-08-11)
3+
## 优化
4+
- dns 增加最大有效时间
5+
- 网络检测可关闭
6+
- 增加速度统计
7+
28
## 8.3.0(2021-07-20)
39
## 增加
410
- 支持 InputStream 上传

QiniuSDK/Utils/QNPHAssetFile.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ - (instancetype)init:(PHAsset *)phAsset error:(NSError *__autoreleasing *)error
5959
NSFileHandle *f = nil;
6060
NSData *d = nil;
6161
if (_fileSize > 16 * 1024 * 1024) {
62-
f = [NSFileHandle fileHandleForReadingAtPath:self.filePath];
62+
f = [NSFileHandle fileHandleForReadingFromURL:[NSURL fileURLWithPath:self.filePath] error:error];
6363
if (f == nil) {
6464
if (error != nil) {
65-
*error = [[NSError alloc] initWithDomain:self.filePath code:kQNFileError userInfo:nil];
65+
*error = [[NSError alloc] initWithDomain:self.filePath code:kQNFileError userInfo:[*error userInfo]];
6666
}
6767
return self;
6868
}
@@ -113,7 +113,10 @@ - (void)close {
113113
if (_file != nil) {
114114
[_file closeFile];
115115
}
116-
[[NSFileManager defaultManager] removeItemAtPath:self.filePath error:nil];
116+
// 如果是导出的 file 删除
117+
if (!self.hasRealFilePath && self.filePath) {
118+
[[NSFileManager defaultManager] removeItemAtPath:self.filePath error:nil];
119+
}
117120
}
118121
}
119122

@@ -134,7 +137,7 @@ - (void)getInfo {
134137
[self getImageInfo];
135138
} else if (PHAssetMediaTypeVideo == self.phAsset.mediaType) {
136139
// 1. 获取 video url
137-
[self getVideoInfo];
140+
// [self getVideoInfo];
138141

139142
// 2. video url 获取失败则导出文件
140143
if (self.filePath == nil) {
@@ -167,7 +170,7 @@ - (void)getVideoInfo {
167170
options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
168171
//不支持icloud上传
169172
options.networkAccessAllowed = NO;
170-
173+
171174
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
172175
[[PHImageManager defaultManager] requestAVAssetForVideo:self.phAsset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
173176
if ([asset isKindOfClass:[AVURLAsset class]]) {

0 commit comments

Comments
 (0)