Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent behaviour between macOS and Linux #8

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions Sources/Zip/QuickZip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
import Foundation

extension Zip {
// Get search path directory. For tvOS Documents directory doesn't exist.
fileprivate class var searchPathDirectory: FileManager.SearchPathDirectory {
#if os(tvOS)
.cachesDirectory
#else
.documentDirectory
#endif
}

/**
Quickly unzips a file.

Expand Down Expand Up @@ -49,11 +40,8 @@ extension Zip {
- Returns: `URL` of the destination folder.
*/
public class func quickUnzipFile(_ path: URL, progress: ((_ progress: Double) -> ())?) throws -> URL {
let fileExtension = path.pathExtension
let fileName = path.lastPathComponent
let directoryName = fileName.replacingOccurrences(of: ".\(fileExtension)", with: "")
let documentsUrl = FileManager.default.urls(for: self.searchPathDirectory, in: .userDomainMask)[0]
let destinationUrl = documentsUrl.appendingPathComponent(directoryName, isDirectory: true)
let directoryName = path.lastPathComponent.replacingOccurrences(of: ".\(path.pathExtension)", with: "")
fpseverino marked this conversation as resolved.
Show resolved Hide resolved
let destinationUrl = FileManager.default.temporaryDirectory.appendingPathComponent(directoryName, isDirectory: true)
try self.unzipFile(path, destination: destinationUrl, progress: progress)
return destinationUrl
}
Expand Down Expand Up @@ -90,8 +78,7 @@ extension Zip {
- Returns: `URL` of the destination folder.
*/
public class func quickZipFiles(_ paths: [URL], fileName: String, progress: ((_ progress: Double) -> ())?) throws -> URL {
let documentsUrl = FileManager.default.urls(for: self.searchPathDirectory, in: .userDomainMask)[0] as URL
let destinationUrl = documentsUrl.appendingPathComponent("\(fileName).zip")
let destinationUrl = FileManager.default.temporaryDirectory.appendingPathComponent("\(fileName).zip")
try self.zipFiles(paths: paths, zipFilePath: destinationUrl, progress: progress)
return destinationUrl
}
Expand Down