[BUG] Opening a non User writable File and saving it causes a traceback
Closed this issue · 2 comments
domsch1988 commented
Describe the bug
When opening a non User writable file without sudo, ash open the file and let's you make changes. On Saving or Quitting ash crashes and Produces a Traceback. The changes are not written and the User doesn't get information on the issue.
To Reproduce
Steps to reproduce the behavior:
- Open any system file that isn't writable by the user
- Make any change to the file
- Quit or Save and Quit
- See error
Expected behavior
Some options:
- Inform the User on opening the file that it isn't writable
- Inform on trying to make changes that they can't be saved
- Inform on Saving the File that this isn't possible
- Don't open the file at all with a Feedback on the commandline
The User needs to get some kind of Feedback on what's happening and some error Handling needs to be in Place.
Log
Traceback (most recent call last):
File "/home/user/.local/bin/ash", line 33, in <module>
sys.exit(load_entry_point('ash-editor==0.1.0.dev13', 'console_scripts', 'ash')())
File "/home/user/.local/lib/python3.10/site-packages/ash/ash_main.py", line 16, in run
app.run()
File "/home/user/.local/lib/python3.10/site-packages/ash/main.py", line 128, in run
ret_code = curses.wrapper(self.app_main)
File "/usr/lib64/python3.10/curses/__init__.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "/home/user/.local/lib/python3.10/site-packages/ash/main.py", line 197, in app_main
self.main_window.show(welcome_msg) # this call returns when main_window() is closed
File "/home/user/.local/lib/python3.10/site-packages/ash/gui/topLevelWindow.py", line 139, in show
aed.perform_action(ch)
File "/home/user/.local/lib/python3.10/site-packages/ash/gui/editor.py", line 170, in perform_action
edit_made = self.keyHandler.handle_keys(ch)
File "/home/user/.local/lib/python3.10/site-packages/ash/gui/editorKeyHandler.py", line 30, in handle_keys
self.save_and_close()
File "/home/user/.local/lib/python3.10/site-packages/ash/gui/editorKeyHandler.py", line 63, in save_and_close
self.handle_save()
File "/home/user/.local/lib/python3.10/site-packages/ash/gui/editorKeyHandler.py", line 426, in handle_save
self.ed.buffer.write_to_disk()
File "/home/user/.local/lib/python3.10/site-packages/ash/core/bufferManager.py", line 197, in write_to_disk
self.write_a_copy(self.filename, self.encoding)
File "/home/user/.local/lib/python3.10/site-packages/ash/core/bufferManager.py", line 184, in write_a_copy
textFile = codecs.open(filename, "w", encoding)
File "/usr/lib64/python3.10/codecs.py", line 905, in open
file = builtins.open(filename, mode, buffering)
Desktop (please complete the following information):
- OS: Fedora 36
- Version 0.1.0 dev12
akashnag commented
Thanks! Will be fixed in the next release.
akashnag commented
Fixed in latest release (0.1.0-dev13)