Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
Copy the file only if we cannot move it.
  • Loading branch information
algera authored and Johan-dutoit committed Jan 28, 2020
1 parent 49e6a77 commit 2ad856a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ios/ImagePickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,14 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

if (videoURL) { // Protect against reported crash
NSError *error = nil;
// iOS 13 b2 may not allow write access to tmp on a trimmed video clip
[fileManager copyItemAtURL:videoURL toURL:videoDestinationURL error:&error];

// If we have write access to the source file, move it. Otherwise use copy.
if ([fileManager isWritableFileAtPath:[videoURL path]]) {
[fileManager moveItemAtURL:videoURL toURL:videoDestinationURL error:&error];
} else {
[fileManager copyItemAtURL:videoURL toURL:videoDestinationURL error:&error];
}

if (error) {
self.callback(@[@{@"error": error.localizedFailureReason}]);
return;
Expand Down

0 comments on commit 2ad856a

Please sign in to comment.