AMSMB2 icon indicating copy to clipboard operation
AMSMB2 copied to clipboard

Incorrect POSIXError (Code 52) when creating duplicate directory in 4.0.0+

Open zytx opened this issue 7 months ago • 1 comments

Description
After upgrading to version 4.0.0+, attempting to create a directory that already exists incorrectly throws a POSIXError with code 52 ("Network dropped connection on reset") instead of the expected file already exists error (EEXIST, POSIX code 17). This breaks backward compatibility with error-handling logic that previously relied on checking for EEXIST.

Steps to Reproduce

  1. Create a directory (e.g., /test/directory)
  2. Attempt to create the same directory again
  3. Observe error:
    POSIXError(_nsError: Error Domain=NSPOSIXErrorDomain Code=52 "Network dropped connection on reset" UserInfo={NSLocalizedDescription=Error code 52:  Create failed with status -1073741771.})
    

zytx avatar May 27 '25 09:05 zytx

I’ve checked the issue. It seems the problem is in libsmb2’s create_cb_1 function.

It should either call smb2_set_nterror or invoke the callback function with a status code (or both, depending on the function), following the pattern used in other callbacks.

As a workaround, you could perform a preflight check to verify the directory’s existence, or consider opening an issue to request a fix in libsmb2 itself.

amosavian avatar Jun 28 '25 07:06 amosavian