your-tools / pycp

cp and mv with a progress bar
MIT License
148 stars 8 forks source link

-g flag crashes pycp #24

Closed 15bitgames closed 7 years ago

15bitgames commented 7 years ago

When I do pycp -g (directory) (directory) I get the following:

Traceback (most recent call last):
  File "/usr/sbin/pycp", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/pycp/main.py", line 114, in main
    errors = transfer_manager.do_transfer()
  File "/usr/lib/python3.6/site-packages/pycp/transfer.py", line 354, in do_transfer
    error = ftm.do_transfer()
  File "/usr/lib/python3.6/site-packages/pycp/transfer.py", line 188, in do_transfer
    self.transfer_file()
  File "/usr/lib/python3.6/site-packages/pycp/transfer.py", line 229, in transfer_file
    self.callback(transfered)
  File "/usr/lib/python3.6/site-packages/pycp/transfer.py", line 339, in on_file_transfer
    self.progress_indicator.on_progress(progress)
  File "/usr/lib/python3.6/site-packages/pycp/progress.py", line 517, in on_progress
    self._render_second_line(progress)
  File "/usr/lib/python3.6/site-packages/pycp/progress.py", line 511, in _render_second_line
    filename=progress.src,
  File "/usr/lib/python3.6/site-packages/pycp/progress.py", line 391, in render
    length, string = component.render(kwargs)
  File "/usr/lib/python3.6/site-packages/pycp/progress.py", line 252, in render
    return len(text), text
TypeError: object of type 'NoneType' has no len()
dmerejkowsky commented 7 years ago

Oops. Looks like I managed to create a race condition in a single-threaded program ;)

15bitgames commented 7 years ago

Glad I could help :)

15bitgames commented 7 years ago

Just to let you know the crash only happens for me on Voidlinux system which uses an AMD Ryzen 1800x. Updated to the latest on debian via pip and it runs fine (thats an AMD A8 APU).

dmerejkowsky commented 7 years ago

Actually it had nothing to do with a race condition :) I just failed to preserve the indentation when I move the code for shorten_path from one file to the other. And I also forgot about those doctests tests.

Should be fixed not. Feel free to take a look at the pull request

15bitgames commented 7 years ago

cheers will try it out :)