fix(ios): tempFilePath called twice if using CameraUsesGeolocation (#612)

This commit is contained in:
jcesarmobile 2020-06-25 18:23:01 +02:00 committed by GitHub
parent ba4f77468f
commit d89c25cd82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -383,6 +383,7 @@ static NSString* toBase64(NSData* data) {
} }
[[self locationManager] startUpdatingLocation]; [[self locationManager] startUpdatingLocation];
} }
data = nil;
} }
} }
break; break;
@ -396,15 +397,10 @@ static NSString* toBase64(NSData* data) {
- (NSString*)tempFilePath:(NSString*)extension - (NSString*)tempFilePath:(NSString*)extension
{ {
NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by Apple (vs [NSFileManager defaultManager]) to be threadsafe
NSString* filePath;
// unique file name // unique file name
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970]; NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp]; NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];
do { NSString* filePath = [NSString stringWithFormat:@"%@/%@%ld.%@", docsPath, CDV_PHOTO_PREFIX, [timeStampObj longValue], extension];
filePath = [NSString stringWithFormat:@"%@/%@%ld.%@", docsPath, CDV_PHOTO_PREFIX, [timeStampObj longValue], extension];
} while ([fileMgr fileExistsAtPath:filePath]);
return filePath; return filePath;
} }