react-native-video-trim 3.0.5 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,4 +13,5 @@ enum ErrorCode: String {
13
13
  case failToSaveToPhoto = "FAIL_TO_SAVE_TO_PHOTO"
14
14
  case failToShare = "FAIL_TO_SHARE"
15
15
  case noPhotoPermission = "NO_PHOTO_PERMISSION"
16
+ case invalidFilePath = "INVALID_FILE_PATH"
16
17
  }
@@ -125,9 +125,10 @@ class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDelegate
125
125
  }
126
126
 
127
127
  let destPath = URL(string: uri)
128
- let newPath = renameFile(at: destPath!, newName: "beforeTrim")
129
-
130
- guard let destPath = newPath else { return }
128
+ guard let destPath = destPath else {
129
+ self.onError(message: "File URL is invalid", code: .invalidFilePath)
130
+ return
131
+ }
131
132
 
132
133
  DispatchQueue.main.async {
133
134
  self.vc = VideoTrimmerViewController()
@@ -700,39 +701,39 @@ class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDelegate
700
701
  }
701
702
  }
702
703
 
703
- private func renameFile(at url: URL, newName: String) -> URL? {
704
- let fileManager = FileManager.default
705
-
706
- // Get the directory of the existing file
707
- let directory = url.deletingLastPathComponent()
708
-
709
- // Get the file extension
710
- let fileExtension = url.pathExtension
711
-
712
- // Create the new file URL with the new name and the same extension
713
- let newFileURL = directory.appendingPathComponent(newName).appendingPathExtension(fileExtension)
714
-
715
- // Check if a file with the new name already exists
716
- if fileManager.fileExists(atPath: newFileURL.path) {
717
- do {
718
- // If the file exists, remove it first to avoid conflicts
719
- try fileManager.removeItem(at: newFileURL)
720
- } catch {
721
- print("Error removing existing file: \(error)")
722
- return nil
723
- }
724
- }
725
-
726
- do {
727
- // Rename (move) the file
728
- try fileManager.moveItem(at: url, to: newFileURL)
729
- print("File renamed successfully to \(newFileURL.absoluteString)")
730
- return newFileURL
731
- } catch {
732
- print("Error renaming file: \(error)")
733
- return nil
734
- }
735
- }
704
+ // private func renameFile(at url: URL, newName: String) -> URL? {
705
+ // let fileManager = FileManager.default
706
+ //
707
+ // // Get the directory of the existing file
708
+ // let directory = url.deletingLastPathComponent()
709
+ //
710
+ // // Get the file extension
711
+ // let fileExtension = url.pathExtension
712
+ //
713
+ // // Create the new file URL with the new name and the same extension
714
+ // let newFileURL = directory.appendingPathComponent(newName).appendingPathExtension(fileExtension)
715
+ //
716
+ // // Check if a file with the new name already exists
717
+ // if fileManager.fileExists(atPath: newFileURL.path) {
718
+ // do {
719
+ // // If the file exists, remove it first to avoid conflicts
720
+ // try fileManager.removeItem(at: newFileURL)
721
+ // } catch {
722
+ // print("Error removing existing file: \(error)")
723
+ // return nil
724
+ // }
725
+ // }
726
+ //
727
+ // do {
728
+ // // Rename (move) the file
729
+ // try fileManager.moveItem(at: url, to: newFileURL)
730
+ // print("File renamed successfully to \(newFileURL.absoluteString)")
731
+ // return newFileURL
732
+ // } catch {
733
+ // print("Error renaming file: \(error)")
734
+ // return nil
735
+ // }
736
+ // }
736
737
  }
737
738
 
738
739
  /// Helper class to manage export session state for legacy API without capturing in closures
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",