Skip to content

Commit

Permalink
Putting folder in remote subdirectory results in error and local file…
Browse files Browse the repository at this point in the history
…s deletion, Fixed #48
  • Loading branch information
p0dalirius committed Jun 21, 2024
1 parent b59b570 commit d0be49c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions smbclientng/core/SMBSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,15 @@ def put_file(self, localpath=None):
callback=f.read
)
f.close()

except (BrokenPipeError, KeyboardInterrupt) as err:
print("[!] Interrupted.")
self.close_smb_session()
self.init_smb_session()
except Exception as err:
print("[!] Failed to upload '%s': %s" % (localfile, err))

except (Exception, PermissionError) as err:
f.set_error(message="[bold red]Failed uploading '%s': %s" % (f.path, err))
f.close(remove=False)
if self.config.debug:
traceback.print_exc()
else:
Expand Down Expand Up @@ -926,13 +929,16 @@ def put_file_recursively(self, localpath=None):
)
f.close()

except (BrokenPipeError, PermissionError) as err:
except (BrokenPipeError, KeyboardInterrupt) as err:
print("[!] Interrupted.")
self.close_smb_session()
self.init_smb_session()

except (Exception, PermissionError) as err:
f.set_error(message="[bold red]Failed uploading '%s': %s" % (f.path, err))
f.close(remove=True)
break
except Exception as err:
f.set_error(message="[bold red]Failed uploading '%s': %s" % (f.path, err))
f.close(remove=True)
f.close(remove=False)
if self.config.debug:
traceback.print_exc()
else:
print("[!] The specified localpath is a file. Use 'put <file>' instead.")
else:
Expand Down

0 comments on commit d0be49c

Please sign in to comment.