hirochachacha / go-smb2

SMB2/3 client library written in Go.
BSD 2-Clause "Simplified" License
350 stars 94 forks source link

Share.Remove returns `remove test.txt: response error: A file cannot be opened because the share access flags are incompatible.` #55

Closed jxsl13 closed 2 years ago

jxsl13 commented 2 years ago
remove test.txt: response error: A file cannot be opened because the share access flags are incompatible.

Hi, I'm trying to wrap this library into the spf13/afero file system interface. For now it is working great, as most of the methods are already provided by the smb2.File/smb2.Share structs.

I'm also trying to test it with a Synology NAS SMB share which works for creating but seemingly not for removing a single file that I created.

I'm getting the above error message.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/8f11e0f3-d545-46cc-97e6-f00569e3e1bc

STATUS_SHARING_VIOLATION
0xC0000043
Posix equivalent: ETXTBSY
Description:
Sharing violation. A requested open mode conflicts with the sharing mode of an existing file handle.

This is the basic test that I wrote in order to create and delete a file. The removal fails.

https://github.com/jxsl13/afero/blob/smb/smbfs/smbfs_test.go#L107

I do not quite understand what might be the problem. Would be glad to help solving this problem.

jxsl13 commented 2 years ago

It was a not closed file handle... :D