From 4e988a66ee88ecb15067d2e517370ebc5d29a569 Mon Sep 17 00:00:00 2001 From: Leonardo Kaminski Ferreira Date: Mon, 18 Oct 2021 09:56:57 -0300 Subject: [PATCH 1/2] [FEAT] Add first test to local animations --- Sources/dotLottieLoader/DotLottieCreator.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/dotLottieLoader/DotLottieCreator.swift b/Sources/dotLottieLoader/DotLottieCreator.swift index 4f57db1..71529d1 100644 --- a/Sources/dotLottieLoader/DotLottieCreator.swift +++ b/Sources/dotLottieLoader/DotLottieCreator.swift @@ -99,8 +99,16 @@ public struct DotLottieCreator { private static func download(from url: URL, to saveUrl: URL, completion: @escaping (Bool) -> Void) { // file is not remote, so just return guard url.isRemoteFile else { - completion(true) - return + let animationData = try? Data(contentsOf: url) + do { + try animationData?.write(to: saveUrl) + completion(true) + return + } catch { + DotLottieUtils.log("Failed to save downloaded data: \(error.localizedDescription)") + completion(false) + return + } } DotLottieUtils.log("Downloading from url: \(url.path)") From f37879154909207f18b5169a963600abe6995818 Mon Sep 17 00:00:00 2001 From: Leonardo Kaminski Ferreira Date: Mon, 18 Oct 2021 10:05:44 -0300 Subject: [PATCH 2/2] [DOCS] Update documentation --- Sources/dotLottieLoader/DotLottieCreator.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/dotLottieLoader/DotLottieCreator.swift b/Sources/dotLottieLoader/DotLottieCreator.swift index 71529d1..35b5e19 100644 --- a/Sources/dotLottieLoader/DotLottieCreator.swift +++ b/Sources/dotLottieLoader/DotLottieCreator.swift @@ -97,7 +97,7 @@ public struct DotLottieCreator { /// - saveUrl: Local file URL to persist /// - completion: Local URL private static func download(from url: URL, to saveUrl: URL, completion: @escaping (Bool) -> Void) { - // file is not remote, so just return + /// file is not remote, save the animation content to the proper same URL and return guard url.isRemoteFile else { let animationData = try? Data(contentsOf: url) do { @@ -105,7 +105,7 @@ public struct DotLottieCreator { completion(true) return } catch { - DotLottieUtils.log("Failed to save downloaded data: \(error.localizedDescription)") + DotLottieUtils.log("Failed to save animation data: \(error.localizedDescription)") completion(false) return }