From 2ad856a1a7a570929a5b6e81328d9445e224a3ed Mon Sep 17 00:00:00 2001 From: Jeff Algera Date: Mon, 7 Oct 2019 14:12:32 -0700 Subject: [PATCH] Code review Copy the file only if we cannot move it. --- ios/ImagePickerManager.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ios/ImagePickerManager.m b/ios/ImagePickerManager.m index 818b415b6..1ed74986b 100644 --- a/ios/ImagePickerManager.m +++ b/ios/ImagePickerManager.m @@ -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;