diff --git a/Sources/Basics/Archiver/ZipArchiver.swift b/Sources/Basics/Archiver/ZipArchiver.swift index ed82f14ae10..f43aa7274be 100644 --- a/Sources/Basics/Archiver/ZipArchiver.swift +++ b/Sources/Basics/Archiver/ZipArchiver.swift @@ -120,7 +120,7 @@ public struct ZipArchiver: Archiver, Cancellable { arguments: [ "/bin/sh", "-c", - "cd \(directory.parentDirectory.underlying.pathString) && zip -r \(destinationPath.pathString) \(directory.basename)", + "cd \(directory.parentDirectory.underlying.pathString) && zip -ry \(destinationPath.pathString) \(directory.basename)", ] ) #endif diff --git a/Tests/BasicsTests/Archiver/ZipArchiverTests.swift b/Tests/BasicsTests/Archiver/ZipArchiverTests.swift index c8a5e113f0b..340935dbade 100644 --- a/Tests/BasicsTests/Archiver/ZipArchiverTests.swift +++ b/Tests/BasicsTests/Archiver/ZipArchiverTests.swift @@ -118,6 +118,7 @@ final class ZipArchiverTests: XCTestCase { try localFileSystem.createDirectory(dir2) try localFileSystem.writeFileContents(dir2.appending("file3.txt"), string: "Hello World 3!") try localFileSystem.writeFileContents(dir2.appending("file4.txt"), string: "Hello World 4!") + try localFileSystem.createSymbolicLink(dir2.appending("file5.txt"), pointingAt: dir1.appending("file2.txt"), relative: true) let archivePath = tmpdir.appending(component: UUID().uuidString + ".zip") try await archiver.compress(directory: rootDir, to: archivePath) @@ -154,6 +155,12 @@ final class ZipArchiverTests: XCTestCase { try? localFileSystem.readFileContents(extractedDir2.appending("file4.txt")), "Hello World 4!" ) + + XCTAssertTrue(localFileSystem.isSymlink(extractedDir2.appending("file5.txt"))) + XCTAssertEqual( + try? localFileSystem.readFileContents(extractedDir2.appending("file5.txt")), + try? localFileSystem.readFileContents(extractedDir1.appending("file2.txt")) + ) } } -} +} \ No newline at end of file