Skip to content

Commit 07db6e4

Browse files
committed
Fall back to os level unzip in case an unzip fails
1 parent a614c8b commit 07db6e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/DocUploadBundle/Zipper.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ enum Zipper {
2323
}
2424

2525
static func unzip(from inputPath: URL, to outputPath: URL, fileOutputHandler: ((_ unzippedFile: URL) -> Void)? = nil) throws {
26-
try Zip.unzipFile(inputPath, destination: outputPath, overwrite: true, password: nil, fileOutputHandler: fileOutputHandler)
26+
do {
27+
try Zip.unzipFile(inputPath, destination: outputPath, overwrite: true, password: nil, fileOutputHandler: fileOutputHandler)
28+
} catch ZipError.unzipFail {
29+
// Try OS level unzip as a fallback
30+
// See https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3069
31+
let unzip = URL(fileURLWithPath: "/usr/bin/unzip")
32+
let process = try Process.run(unzip, arguments: ["-q", inputPath.path, "-d", outputPath.path])
33+
process.waitUntilExit()
34+
}
2735
}
2836
}
2937

0 commit comments

Comments
 (0)