Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu committed Dec 11, 2024
1 parent 6d44cd5 commit ce2abfd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 44 deletions.
12 changes: 5 additions & 7 deletions Sources/Shared/Toolkit/ZIP/ZIPFoundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import ReadiumZIPFoundation

/// An ``ArchiveOpener`` able to open ZIP archives using ZIPFoundation.
public final class ZIPFoundationArchiveOpener: ArchiveOpener {

public init() {}

public func open(resource: any Resource, format: Format) async -> Result<ContainerAsset, ArchiveOpenError> {
guard
format.conformsTo(.zip),
Expand Down Expand Up @@ -152,14 +151,13 @@ private actor ZIPFoundationResource: Resource, Loggable {
}

func stream(range: Range<UInt64>?, consume: @escaping (Data) -> Void) async -> ReadResult<Void> {
if range != nil {
}
if range != nil {}

return await archive().flatMap { archive in
guard let entry = archive[entryPath] else {
return .failure(.decoding("No entry found in the ZIP at \(entryPath)"))
}

do {
if let range = range {
try archive.extractRange(range, of: entry) { data in
Expand All @@ -176,12 +174,12 @@ private actor ZIPFoundationResource: Resource, Loggable {
}
}
}

private var _archive: ReadResult<ReadiumZIPFoundation.Archive>?
private func archive() async -> ReadResult<ReadiumZIPFoundation.Archive> {
if _archive == nil {
do {
_archive = .success(try ReadiumZIPFoundation.Archive(url: file.url, accessMode: .read, pathEncoding: nil))
_archive = try .success(ReadiumZIPFoundation.Archive(url: file.url, accessMode: .read))
} catch {
_archive = .failure(.decoding(error))
}
Expand Down
1 change: 0 additions & 1 deletion TestApp/Sources/App/Readium.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import Foundation
import ReadiumAdapterGCDWebServer
import ReadiumAdapterZIPFoundation
import ReadiumNavigator
import ReadiumShared
import ReadiumStreamer
Expand Down
1 change: 0 additions & 1 deletion Tests/Adapters/ZIPFoundationTests/Fixtures

This file was deleted.

29 changes: 0 additions & 29 deletions Tests/Adapters/ZIPFoundationTests/Fixtures.swift

This file was deleted.

11 changes: 5 additions & 6 deletions Tests/SharedTests/Toolkit/Archive/ZIPFoundationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import XCTest
private let fixtures = Fixtures(path: "Archive")

class ZIPFoundationTests: XCTestCase {

private func container(for filename: String) async throws -> Container {
try await ZIPFoundationContainer.make(file: fixtures.url(for: filename)).get()
}

func testOpenSuccess() async throws {
_ = try await container(for: "test.zip")
}
Expand Down Expand Up @@ -107,9 +106,9 @@ class ZIPFoundationTests: XCTestCase {
" ZIP.\n"
)
}

func testRandomCompressedRead() async throws {
for _ in 0..<100 {
for _ in 0 ..< 100 {
let container = try await container(for: "test.zip")
let entry = try XCTUnwrap(container[AnyURL(path: "A folder/wasteland-cover.jpg")!])
let length: UInt64 = 103_477
Expand All @@ -119,9 +118,9 @@ class ZIPFoundationTests: XCTestCase {
_ = try await entry.read(range: range).get()
}
}

func testRandomStoredRead() async throws {
for _ in 0..<100 {
for _ in 0 ..< 100 {
let container = try await container(for: "test.zip")
let entry = try XCTUnwrap(container[AnyURL(path: "uncompressed.jpg")!])
let length: UInt64 = 279_551
Expand Down

0 comments on commit ce2abfd

Please sign in to comment.