From 1d48c3a73cae5b133b3a448a31777c8bf971df4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Rodri=CC=81guez?= Date: Fri, 29 Oct 2021 09:16:37 +0200 Subject: [PATCH] Refactor out filename generators --- ios/Plugin/VideoEditorPlugin.swift | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ios/Plugin/VideoEditorPlugin.swift b/ios/Plugin/VideoEditorPlugin.swift index aa65587..d815655 100644 --- a/ios/Plugin/VideoEditorPlugin.swift +++ b/ios/Plugin/VideoEditorPlugin.swift @@ -91,27 +91,15 @@ public class VideoEditorPlugin: CAPPlugin { } func getDestVideoUrl() -> URL { - var url: URL - var counter = 0; - - repeat { - counter += 1 - url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("vid-\(counter).mp4") - } while FileManager.default.fileExists(atPath: url.path) - - return url + return URL(fileURLWithPath: NSTemporaryDirectory()) + .appendingPathComponent(NSUUID().uuidString) + .appendingPathExtension("mp4") } func getDestImageUrl() -> URL { - var url: URL - var counter = 0; - - repeat { - counter += 1 - url = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("th-\(counter).jpg") - } while FileManager.default.fileExists(atPath: url.path) - - return url + return URL(fileURLWithPath: NSTemporaryDirectory()) + .appendingPathComponent(NSUUID().uuidString) + .appendingPathExtension("jpg") } func createMediaFile(url: URL) -> JSObject {