Fix. #71, Temp workaround for StreamTask issue

This commit is contained in:
Amir Abbas
2017-12-26 11:22:05 +03:30
parent d38748153d
commit b17d92350c
2 changed files with 6 additions and 7 deletions
+3 -3
View File
@@ -324,8 +324,8 @@ public class FileProviderStreamTask: URLSessionTask, StreamDelegate {
}
self._state = .canceling
inputStream?.setValue(kCFBooleanTrue, forKey: kCFStreamPropertyShouldCloseNativeSocket as String)
outputStream?.setValue(kCFBooleanTrue, forKey: kCFStreamPropertyShouldCloseNativeSocket as String)
//inputStream?.setValue(kCFBooleanTrue, forKey: kCFStreamPropertyShouldCloseNativeSocket as String)
//outputStream?.setValue(kCFBooleanTrue, forKey: kCFStreamPropertyShouldCloseNativeSocket as String)
self.inputStream?.close()
self.outputStream?.close()
@@ -681,7 +681,7 @@ public class FileProviderStreamTask: URLSessionTask, StreamDelegate {
public extension URLSession {
/// Creates a bidirectional stream task to a given host and port.
func fpstreamTask(withHostName hostname: String, port: Int) -> FileProviderStreamTask {
return FileProviderStreamTask(session: self, host: hostname, port: port)
return FileProviderStreamTask(session: self, host: hostname, port: port, useURLSession: false)
}
/**
+3 -4
View File
@@ -204,7 +204,7 @@ internal extension FTPFileProvider {
throw error
}
guard let response = response, let destString = response.components(separatedBy: " ").flatMap({ $0 }).last.flatMap(String.init) else {
guard let response = response, let destString = response.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: " ").last else {
throw self.urlError("", code: .badServerResponse)
}
@@ -308,6 +308,7 @@ internal extension FTPFileProvider {
func ftpList(_ task: FileProviderStreamTask, of path: String, useMLST: Bool, completionHandler: @escaping (_ contents: [String], _ error: Error?) -> Void) {
self.ftpDataConnect(task) { (dataTask, error) in
if let error = error {
completionHandler([], error)
return
@@ -321,10 +322,8 @@ internal extension FTPFileProvider {
var success = false
let command = useMLST ? "MLSD \(path)" : "LIST \(path)"
self.execute(command: command, on: task, minLength: 20, afterSend: { error in
// starting passive task
let timeout = self.session.configuration.timeoutIntervalForRequest
DispatchQueue.global().async {
let timeout = self.session.configuration.timeoutIntervalForRequest
var finalData = Data()
var eof = false
var error: Error?