-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unable to Delete Broken Symlink #308
Comments
Thanks for the report. I just did a quick investigation based on the source code. Are you using the latest version? Which SMB server do you use ? I am looking at the code and I see that The code has explicit support for this # Ensures we delete the symlink (if present) and don't follow it down.
co = CreateOptions.FILE_OPEN_REPARSE_POINT smbprotocol/src/smbclient/_os.py Lines 1202 to 1208 in af78f1a
If the latest version still doesn't work, then this need further investigation Documentation for FILE_OPEN_REPARSE_POINT is here |
Thanks for the quick reply. Yes, I am using the latest version of the library. I have verified that the unlink() function calls remove(), which in turn uses _delete() with the CreateOptions.FILE_OPEN_REPARSE_POINT option. However, when I try to delete a broken symlink (pointing to a non-existent file), the operation fails with the error "file not found." I haven't tried modifying the "create_options" Would it be worth trying a similar approach here? Thanks for your support |
Are you able to share the full error and traceback? @adiroiban is right in that the delete operation is done with |
|
This may be a problem with how Samba deals with broken symlinks. On Windows I have the following
Then I run
I can also successfully unlink/remove it on the Windows share import smbclient
smbclient.unlink(r"\\host.domain.test\d$\test\link-bad") I'll have to try and setup a Samba server using your configuration to see if maybe the problem is on the Samba end or in how we interpret some of the results. |
I setup a Samba host with this setup, the share directory on the Samba server side is
It looks like Samba just pretends the link does not exist, I cannot even see it when enumerating the directory
This explains why we cannot remove the broken link as Samba is acting like it doesn't exist at all. I recommend trying to run |
The problem is that I can't verify if it exists so in trying to create it I get an error saying it exists. |
Sure but if Samba doesn't even report the symlink in the directory listing then it's not exposing it in any way that can be accessed through SMB. This is a problem on their side and nothing I can do from a client perspective. |
Hello,
I have encountered a problem when trying to delete a broken symbolic link.
The symbolic link points to a nonexistent file, and when you try to delete it, the operation fails, saying that the file does not exist.
Steps to Reproduce:
Obviously, if the symlink is not broken then the unlink method works correctly
The text was updated successfully, but these errors were encountered: