Coder Social home page Coder Social logo

Comments (2)

BTRLabs avatar BTRLabs commented on June 11, 2024

The "let cbdata = ..." line is the one that is at the heart of the problem (context.swift - line 343). When downloadItem() is called, this func is called twice before erroring out. The first time it appears to execute correctly (i.e., status = 0), but the second time through it fails (i.e., status = -22).
`

static let generic_handler: smb2_command_cb = { smb2, status, command_data, cbdata in
    do {
        guard try smb2.unwrap().pointee.fd >= 0 else { return }
        let cbdata = try cbdata.unwrap().bindMemory(to: CBData.self, capacity: 1).pointee
        if status != SMB2_STATUS_SUCCESS {
            cbdata.result = status
        }
        cbdata.dataHandler?(command_data)
        cbdata.isFinished = true
    } catch { }
}

`

from amsmb2.

BTRLabs avatar BTRLabs commented on June 11, 2024

So it turns out that when a path is provided to downloadItem() or contents() that "DOES NOT EXIST", LIBSMB2 responds with an ambiguous "Error Code 22 STATUS_INVALID_PARAMETER" error response, rather than a clear "Path does not exist" error response.

The root of the issue experienced was due to not trimming the leading slash from the path that was returned from the URLResourceKey.pathKey value from contentsOfDirectory(). Trimming that leading slash has AMSMB2 humming perfectly now.

Sorry for the multiple comments, but it simply wasn't an obvious error response and cost the better part of 8 hours trying to debug. Only after connecting against a Linux SMB share to gut check things and receiving the same error did it occur that this might be the case.

from amsmb2.

Related Issues (20)

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.