Skip to content

Commit

Permalink
修复可能出现死循环的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liujunhua committed Jun 18, 2021
1 parent 68b4631 commit e267a39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Sources/General/SessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ extension SessionManager {

public func start(_ task: DownloadTask, onMainQueue: Bool = true, handler: Handler<DownloadTask>? = nil) {
operationQueue.async {
guard let _ = self.fetchTask(task.url) else {
self.log(.error("can't start downloadTask", error: TiercelError.fetchDownloadTaskFailed(url: task.url)))
return
}
self._start(task, onMainQueue: onMainQueue, handler: handler)
}
}
Expand Down Expand Up @@ -479,6 +483,10 @@ extension SessionManager {

public func suspend(_ task: DownloadTask, onMainQueue: Bool = true, handler: Handler<DownloadTask>? = nil) {
operationQueue.async {
guard let _ = self.fetchTask(task.url) else {
self.log(.error("can't suspend downloadTask", error: TiercelError.fetchDownloadTaskFailed(url: task.url)))
return
}
task.suspend(onMainQueue: onMainQueue, handler: handler)
}
}
Expand All @@ -500,6 +508,10 @@ extension SessionManager {

public func cancel(_ task: DownloadTask, onMainQueue: Bool = true, handler: Handler<DownloadTask>? = nil) {
operationQueue.async {
guard let _ = self.fetchTask(task.url) else {
self.log(.error("can't cancel downloadTask", error: TiercelError.fetchDownloadTaskFailed(url: task.url)))
return
}
task.cancel(onMainQueue: onMainQueue, handler: handler)
}
}
Expand All @@ -526,6 +538,10 @@ extension SessionManager {

public func remove(_ task: DownloadTask, completely: Bool = false, onMainQueue: Bool = true, handler: Handler<DownloadTask>? = nil) {
operationQueue.async {
guard let _ = self.fetchTask(task.url) else {
self.log(.error("can't remove downloadTask", error: TiercelError.fetchDownloadTaskFailed(url: task.url)))
return
}
task.remove(completely: completely, onMainQueue: onMainQueue, handler: handler)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tiercel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 3.2.1;
MARKETING_VERSION = 3.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Daniels.Tiercel;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -589,7 +589,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 3.2.1;
MARKETING_VERSION = 3.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.Daniels.Tiercel;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down

0 comments on commit e267a39

Please sign in to comment.