Commit cbf5ecc2 by Sarkizz

修正解压逻辑

parent 2fc314fe
......@@ -396,14 +396,19 @@ extension MRFiles {
to directory: URL,
password: String? = nil,
progress: ((_ progress: Double) -> Void)? = nil,
completion: ((_ fileURL: URL?, _ error: Error?) -> Void)? = nil) {
fileOutput: ((_ url: URL) -> Void)? = nil,
completion: ((_ error: Error?) -> Void)? = nil) {
do {
try Zip.unzipFile(url, destination: directory, overwrite: true, password: password, progress: progress, fileOutputHandler: { url in
completion?(url, nil)
})
try Zip.unzipFile(url,
destination: directory,
overwrite: true,
password: password,
progress: progress,
fileOutputHandler: fileOutput)
completion?(nil)
} catch let err {
progress?(1)
completion?(nil, error(MRFilesErrorCode.unzipError, msg: "文件解压失败"))
completion?(error(MRFilesErrorCode.unzipError, msg: "文件解压失败"))
#if DEBUG
print("MRFile unzip failed: \(err)\n")
#endif
......@@ -535,9 +540,15 @@ extension URL {
public func unzip(to directory: URL? = nil,
password: String? = nil,
progress: ((_ progress: Double) -> Void)? = nil,
completion: ((_ fileURL: URL?, _ error: Error?) -> Void)? = nil) {
fileOutput: ((_ url: URL) -> Void)? = nil,
completion: ((_ error: Error?) -> Void)? = nil) {
let destination = directory ?? self.deletingLastPathComponent()
MRFiles.unzip(self, to: destination, password: password, progress: progress, completion: completion)
MRFiles.unzip(self,
to: destination,
password: password,
progress: progress,
fileOutput: fileOutput,
completion: completion)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment