Coder Social home page Coder Social logo

zippinch's People

Contributors

buh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zippinch's Issues

Cocoa error 5377 when trying to download Entry

I seem to be hitting a The operation couldn’t be completed. (Cocoa error 5377.) error when attempting to download a ~13MB entry from within a remote ZIP archive approximately ~12-13GB in size.

Here is the stripped down version of the code I am running:

//  test.swift

import Foundation
import ZipPinch

enum TestError: Error, CustomStringConvertible {
    case generalError(String)

    var description: String {
        switch self {
        case let .generalError(string):
            return string
        }
    }
}

func fetchFile(_ filePath: String, from url: String) async throws -> Data {
    guard let url: URL = .init(string: url) else {
        throw TestError.generalError("Invalid URL '\(url)'")
    }
    
    let request: URLRequest = .init(url: url)
    let entries: [ZIPEntry] = try await URLSession.shared.zipEntries(for: request)

    guard let entry: ZIPEntry = entries.first(where: { $0.filePath == filePath }) else {
        throw TestError.generalError("'\(filePath)' not found in '\(url)'")
    }

    return try await URLSession.shared.zipEntryData(entry, for: request)
}

let filePath: String = "BuildManifest.plist"
let url: String = "https://updates.cdn-apple.com/2024SpringFCS/fullrestores/062-01897/C874907B-9F82-4109-87EB-6B3C9BF1507D/UniversalMac_14.5_23F79_Restore.ipsw"

do {
    let buildManifest: Data = try await fetchFile(filePath, from: url)
    // do things with buildManifest...
} catch {
    if let error: TestError = error as? TestError {
        print(error)
    } else {
        print(error.localizedDescription)
    }
}

When I try a different file, eg. let filePath: String = "Restore.plist", the app crashes with the following stacktrace:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** NSAllocateMemoryPages(18446744073709488500) failed'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000019f6baccc __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000019f1a2788 objc_exception_throw + 60
	2   Foundation                          0x00000001a07b7200 NSAllocateMemoryPages + 184
	3   Foundation                          0x00000001a0724b64 -[_NSPlaceholderData initWithBytes:length:copy:deallocator:] + 132
	4   Test                                0x000000010000f634 $sSo6NSDataC5bytes6lengthABSVSg_SitcfcTO + 32
	5   Test                                0x000000010000f604 $sSo6NSDataC5bytes6lengthABSVSg_SitcfC + 52
	6   Test                                0x000000010000cd38 $sSo12NSURLSessionC8ZipPinchE12zipEntryData_3for8delegate8progress10Foundation0F0VAC8ZIPEntryV_AH10URLRequestVSo0A12TaskDelegate_pSgAC11ZIPProgressVSgtYaKFTY4_ + 2092
	7   Test                                0x0000000100004e61 $s4Test9fetchFile_4from10Foundation4DataVSS_SStYaKFTQ3_ + 1
	8   Test                                0x0000000100003c99 async_MainTQ0_ + 1
	9   Test                                0x0000000100004179 $sIetH_yts5Error_pIegHrzo_TRTQ0_ + 1
	10  Test                                0x00000001000042a1 $sIetH_yts5Error_pIegHrzo_TRTATQ0_ + 1
	11  libswift_Concurrency.dylib          0x0000000265c5b0f9 _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1
)
libc++abi: terminating due to uncaught exception of type NSException

I am running Swift 5.10:

swift --version              
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Please let me know if I'm holding it wrong, and thank you for your work on this project 🙌

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.