Skip to content

Commit

Permalink
Fix file deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan committed Nov 19, 2024
1 parent b1966ea commit 5d425c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions smbclientng/core/InteractiveShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,19 @@ def command_rm(self, arguments, command):
# SMB share needed : Yes

for path_to_file in arguments:
# Wildcard
# Check if the path is absolute
# Fullpath is required to check if path is a file
if ntpath.isabs(path_to_file):
full_path = ntpath.normpath(path_to_file)
else:
# Relative path, construct full path
full_path = ntpath.normpath(ntpath.join(self.sessionsManager.current_session.smb_cwd, path_to_file))
# Wildcard handling
if '*' in path_to_file:
self.sessionsManager.current_session.rm(path=path_to_file)
# File
elif self.sessionsManager.current_session.path_exists(path_to_file):
if self.sessionsManager.current_session.path_isfile(path_to_file):
if self.sessionsManager.current_session.path_isfile(full_path):
try:
self.sessionsManager.current_session.rm(path=path_to_file)
except Exception as e:
Expand Down

0 comments on commit 5d425c8

Please sign in to comment.