Skip to content

Commit 8a2a2fb

Browse files
committed
Camera Upload no longer functioning on iOS after recent update 3.2.1 (#5038)
Remove the temporary directory before fetch and enumerate the assets causes the error with the database (SQLite 14)
1 parent 9263e15 commit 8a2a2fb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

iMEGA/Camera uploads/CameraUploads.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ - (void)getAssetsForUpload {
179179
return;
180180
}
181181

182+
if (![[NSFileManager defaultManager] fileExistsAtPath:NSTemporaryDirectory()]) {
183+
[[NSFileManager defaultManager] createDirectoryAtPath:NSTemporaryDirectory() withIntermediateDirectories:YES attributes:nil error:nil];
184+
}
185+
182186
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
183187
PHFetchResult *assetsFetchResult = nil;
184188

@@ -193,16 +197,15 @@ - (void)getAssetsForUpload {
193197

194198
MEGALogInfo(@"Retrieved assets %ld", assetsFetchResult.count);
195199

196-
for (PHAsset *asset in assetsFetchResult) {
200+
[assetsFetchResult enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger index, BOOL *stop) {
197201
if (asset.mediaType == PHAssetMediaTypeVideo && self.isUploadVideosEnabled && ([asset.creationDate timeIntervalSince1970] > [self.lastUploadVideoDate timeIntervalSince1970])) {
198202
MEGAAssetOperation *uploadAssetsOperation = [[MEGAAssetOperation alloc] initWithPHAsset:asset parentNode:cameraUploadsNode automatically:YES];
199203
[_assetsOperationQueue addOperation:uploadAssetsOperation];
200204
} else if (asset.mediaType == PHAssetMediaTypeImage && ([asset.creationDate timeIntervalSince1970] > [self.lastUploadPhotoDate timeIntervalSince1970])) {
201205
MEGAAssetOperation *uploadAssetsOperation = [[MEGAAssetOperation alloc] initWithPHAsset:asset parentNode:cameraUploadsNode automatically:YES];
202206
[_assetsOperationQueue addOperation:uploadAssetsOperation];
203-
}
204-
}
205-
207+
}
208+
}];
206209
} else {
207210
__block NSInteger totalAssets = 0;
208211

0 commit comments

Comments
 (0)