From 9971e0b45d23587579b2c6efb0be52dfc207da31 Mon Sep 17 00:00:00 2001 From: Brandon Evans Date: Fri, 1 Jan 2021 10:37:47 -0700 Subject: [PATCH] Remove Promise retry functions We'll need to reimplement these later when implementing installation --- Xcodes.xcodeproj/project.pbxproj | 4 ---- Xcodes/Backend/Promise+.swift | 40 -------------------------------- 2 files changed, 44 deletions(-) delete mode 100644 Xcodes/Backend/Promise+.swift diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index 7a04c70..ed443f8 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -43,7 +43,6 @@ CABFA9BD2592EEEA00380FEE /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9A92592EEE900380FEE /* Environment.swift */; }; CABFA9BF2592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B32592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift */; }; CABFA9C12592EEEA00380FEE /* Version+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9A82592EEE900380FEE /* Version+.swift */; }; - CABFA9C22592EEEA00380FEE /* Promise+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B02592EEEA00380FEE /* Promise+.swift */; }; CABFA9C32592EEEA00380FEE /* Downloads.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B92592EEEA00380FEE /* Downloads.swift */; }; CABFA9C52592EEEA00380FEE /* FileManager+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B82592EEEA00380FEE /* FileManager+.swift */; }; CABFA9C72592EEEA00380FEE /* Entry+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B22592EEEA00380FEE /* Entry+.swift */; }; @@ -169,7 +168,6 @@ CABFA9AB2592EEE900380FEE /* URLRequest+Apple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLRequest+Apple.swift"; sourceTree = ""; }; CABFA9AC2592EEE900380FEE /* Foundation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Foundation.swift; sourceTree = ""; }; CABFA9AE2592EEE900380FEE /* Path+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Path+.swift"; sourceTree = ""; }; - CABFA9B02592EEEA00380FEE /* Promise+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+.swift"; sourceTree = ""; }; CABFA9B22592EEEA00380FEE /* Entry+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Entry+.swift"; sourceTree = ""; }; CABFA9B32592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+DownloadTaskPublisher.swift"; sourceTree = ""; }; CABFA9B42592EEEA00380FEE /* Process.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Process.swift; sourceTree = ""; }; @@ -335,7 +333,6 @@ CAE4248B259A68B800B8B246 /* Optional+IsNotNil.swift */, CABFA9AE2592EEE900380FEE /* Path+.swift */, CABFA9B42592EEEA00380FEE /* Process.swift */, - CABFA9B02592EEEA00380FEE /* Promise+.swift */, CAFBDB902598FE80003DCC5A /* SelectedXcode.swift */, CABFA9AB2592EEE900380FEE /* URLRequest+Apple.swift */, CABFA9B32592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift */, @@ -647,7 +644,6 @@ CA9FF8F525959CE000E47BAF /* HelperInstaller.swift in Sources */, CA73510D257BFCEF00EA9CF8 /* NSAttributedString+.swift in Sources */, CAFBDB952598FE96003DCC5A /* FocusedValues.swift in Sources */, - CABFA9C22592EEEA00380FEE /* Promise+.swift in Sources */, CAFBDC68259A308B003DCC5A /* InfoPane.swift in Sources */, CAA1CB4D255A5CFD003FD669 /* SignInPhoneListView.swift in Sources */, CAFBDC6C259A3098003DCC5A /* View+Conditional.swift in Sources */, diff --git a/Xcodes/Backend/Promise+.swift b/Xcodes/Backend/Promise+.swift deleted file mode 100644 index 9398cd7..0000000 --- a/Xcodes/Backend/Promise+.swift +++ /dev/null @@ -1,40 +0,0 @@ -import Foundation -import PromiseKit - -/// Attempt and retry a task that fails with resume data up to `maximumRetryCount` times -func attemptResumableTask( - maximumRetryCount: Int = 3, - delayBeforeRetry: DispatchTimeInterval = .seconds(2), - _ body: @escaping (Data?) -> Promise -) -> Promise { - var attempts = 0 - func attempt(with resumeData: Data? = nil) -> Promise { - attempts += 1 - return body(resumeData).recover { error -> Promise in - guard - attempts < maximumRetryCount, - let resumeData = (error as NSError).userInfo[NSURLSessionDownloadTaskResumeData] as? Data - else { throw error } - - return after(delayBeforeRetry).then(on: nil) { attempt(with: resumeData) } - } - } - return attempt() -} - -/// Attempt and retry a task up to `maximumRetryCount` times -func attemptRetryableTask( - maximumRetryCount: Int = 3, - delayBeforeRetry: DispatchTimeInterval = .seconds(2), - _ body: @escaping () -> Promise -) -> Promise { - var attempts = 0 - func attempt() -> Promise { - attempts += 1 - return body().recover { error -> Promise in - guard attempts < maximumRetryCount else { throw error } - return after(delayBeforeRetry).then(on: nil) { attempt() } - } - } - return attempt() -}