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

Restore Minizip in ReadiumShared #551

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "dexman/Minizip" ~> 1.4.0
github "krzyzanowskim/CryptoSwift" ~> 1.8.0
github "ra1028/DifferenceKit" ~> 1.3.0
github "readium/Fuzi" ~> 4.0.0
Expand Down
19 changes: 1 addition & 18 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ let package = Package(
// Adapters to third-party dependencies.
.library(name: "ReadiumAdapterGCDWebServer", targets: ["ReadiumAdapterGCDWebServer"]),
.library(name: "ReadiumAdapterLCPSQLite", targets: ["ReadiumAdapterLCPSQLite"]),
.library(name: "ReadiumAdapterMinizip", targets: ["ReadiumAdapterMinizip"]),
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.8.0"),
Expand All @@ -39,6 +38,7 @@ let package = Package(
dependencies: [
"ReadiumInternal",
"SwiftSoup",
"Zip",
.product(name: "ReadiumFuzi", package: "Fuzi"),
.product(name: "ReadiumZIPFoundation", package: "ZIPFoundation"),
],
Expand Down Expand Up @@ -159,23 +159,6 @@ let package = Package(
path: "Sources/Adapters/LCPSQLite"
),

.target(
name: "ReadiumAdapterMinizip",
dependencies: [
"ReadiumShared",
"Zip",
],
path: "Sources/Adapters/Minizip"
),
.testTarget(
name: "ReadiumAdapterMinizipTests",
dependencies: ["ReadiumAdapterMinizip"],
path: "Tests/Adapters/MinizipTests",
resources: [
.copy("Fixtures"),
]
),

.target(
name: "ReadiumInternal",
path: "Sources/Internal"
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ Note that Carthage will build all Readium modules and their dependencies, but yo

Refer to the following table to know which dependencies are required for each Readium library.

| | `ReadiumShared` | `ReadiumStreamer` | `ReadiumNavigator` | `ReadiumOPDS` | `ReadiumLCP` | `ReadiumAdapterGCDWebServer` | `ReadiumAdapterLCPSQLite` | `ReadiumAdapterMinizip` |
|------------------------|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|------------------------------|---------------------------|-------------------------|
| **`ReadiumShared`** | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| **`ReadiumInternal`** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | |
| `CryptoSwift` | | :heavy_check_mark: | | | :heavy_check_mark: | | | |
| `DifferenceKit` | | | :heavy_check_mark: | | | | | |
| `ReadiumFuzi` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | |
| `ReadiumGCDWebServer` | | | | | | :heavy_check_mark: | | |
| `ReadiumZIPFoundation` | :heavy_check_mark: | | | | :heavy_check_mark: | | | |
| `Minizip` | | | | | | | | :heavy_check_mark: |
| `SQLite.swift` | | | | | | | :heavy_check_mark: | |
| `SwiftSoup` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | |
| | `ReadiumShared` | `ReadiumStreamer` | `ReadiumNavigator` | `ReadiumOPDS` | `ReadiumLCP` | `ReadiumAdapterGCDWebServer` | `ReadiumAdapterLCPSQLite` |
|------------------------|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|------------------------------|---------------------------|
| **`ReadiumShared`** | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| **`ReadiumInternal`** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| `CryptoSwift` | | :heavy_check_mark: | | | :heavy_check_mark: | | |
| `DifferenceKit` | | | :heavy_check_mark: | | | | |
| `ReadiumFuzi` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| `ReadiumGCDWebServer` | | | | | | :heavy_check_mark: | |
| `ReadiumZIPFoundation` | :heavy_check_mark: | | | | :heavy_check_mark: | | |
| `Minizip` | :heavy_check_mark: | | | | | | |
| `SQLite.swift` | | | | | | | :heavy_check_mark: |
| `SwiftSoup` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |

### CocoaPods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
//

import Foundation
import ReadiumShared

/// An ``ArchiveOpener`` able to open ZIP archives using Minizip.
///
/// Compared to the default ZIPFoundation implementation shipped with
/// ReadiumShared, the ``MinizipArchiveOpener``:
///
/// Compared to the ``ZIPFoundationArchiveOpener`` it:
/// - Does not support HTTP streaming of ZIP archives.
/// - Has better performance when reading an LCP-protected package containing
/// large deflated ZIP entries (instead of stored).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import Foundation
import Minizip
import ReadiumShared

/// A ZIP ``Container`` using the Minizip library.
final class MinizipContainer: Container, Loggable {
Expand Down
17 changes: 6 additions & 11 deletions Sources/Shared/Toolkit/ZIP/ZIPArchiveOpener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
import Foundation

/// An ``ArchiveOpener`` for ZIP resources.
public class ZIPArchiveOpener: ArchiveOpener {
private let opener = ZIPFoundationArchiveOpener()

public init() {}

public func open(resource: any Resource, format: Format) async -> Result<ContainerAsset, ArchiveOpenError> {
await opener.open(resource: resource, format: format)
}

public func sniffOpen(resource: any Resource) async -> Result<ContainerAsset, ArchiveSniffOpenError> {
await opener.sniffOpen(resource: resource)
public class ZIPArchiveOpener: CompositeArchiveOpener {
public init() {
super.init([
MinizipArchiveOpener(),
ZIPFoundationArchiveOpener(),
])
}
}
Loading