From ee700eea6335a5c6c5b27b4f557048ab7905badb Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 7 Oct 2024 15:26:58 -0700 Subject: [PATCH] run update extensions --- modules/Share-with-Bluesky/ShareViewController.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/Share-with-Bluesky/ShareViewController.swift b/modules/Share-with-Bluesky/ShareViewController.swift index 79f081737f..a7af2b19cd 100644 --- a/modules/Share-with-Bluesky/ShareViewController.swift +++ b/modules/Share-with-Bluesky/ShareViewController.swift @@ -151,16 +151,20 @@ class ShareViewController: UIViewController { private func saveVideoWithInfo(_ dataUrl: URL) -> String? { let ext = String(dataUrl.lastPathComponent.split(separator: ".").last ?? "mp4") - guard let tempUrl = getTempUrl(ext: ext), - let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else { + guard let tempUrl = getTempUrl(ext: ext) else { return nil } - let size = track.naturalSize.applying(track.preferredTransform) let data = try? Data(contentsOf: dataUrl) try? data?.write(to: tempUrl) - return "\(tempUrl.absoluteString)|\(size.width)||\(size.height)" + guard let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else { + _ = try? FileManager().removeItem(at: tempUrl) + return nil + } + + let size = track.naturalSize.applying(track.preferredTransform) + return "\(tempUrl.absoluteString)|\(size.width)|\(size.height)" } private func completeRequest() {