olivierkes / manuskript

A open-source tool for writers
http://www.theologeek.ch/manuskript
GNU General Public License v3.0
1.74k stars 230 forks source link

Program crashes if project contains a PDF file #1308

Open tustin2121 opened 1 month ago

tustin2121 commented 1 month ago

I downloaded a couple PDFs from the web and put them in my "Research" folder in the outline, thinking that I could theoretically open them and view them in manuskript later, like how Scrivener worked. Or at the very least, manuskript would ignore them. Instead, when I next opened the project, manuskript immediately crashed with an uncaught exception:

An unhandled exception has occurred!
Traceback (most recent call last):
  File "manuskript\ui\welcome.py", line 148, in loadRecentFile
  File "manuskript\mainWindow.py", line 936, in loadProject
  File "manuskript\mainWindow.py", line 1235, in loadDatas
  File "manuskript\loadSave.py", line 68, in loadProject
  File "manuskript\load_save\version_1.py", line 696, in loadProject
  File "codecs.py", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: invalid continuation byte
CRITICAL> An unhandled exception has occurred!
Traceback (most recent call last):
  File "manuskript\ui\welcome.py", line 148, in loadRecentFile
  File "manuskript\mainWindow.py", line 936, in loadProject
  File "manuskript\mainWindow.py", line 1235, in loadDatas
  File "manuskript\loadSave.py", line 68, in loadProject
  File "manuskript\load_save\version_1.py", line 696, in loadProject
  File "codecs.py", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: invalid continuation byte

Apparently, manuskript just assumes everything stored in the project directory is a utf8 text file and doesn't actually do any checking of extensions or magic numbers or anything? It should at the very least be handling disk read errors. That's like lesson 1 on external I/O...

Manuskript crashed every time I attempted to reopen the project until I remembered the PDF files and moved them out of the project folder tree. Then it was fine (if annoyingly slow, but that's an unrelated issue).

Version 0.16.1-5a10925 Running on Windows 10. Software Versions in Use:

rzw commented 1 month ago

Yes, dealing with resource-files or attachments is fiddly. I too thought: Why doesn't Manuskript just ignore them? The good thing about it is that it keeps the project tree clean. What I ended up doing was to create one or more folders at the same level as the msk-file and refer to the folder(s) or files with links like so:

Notice that I use a prefix identical to the one I use for the msk-file. Relative paths don't seem to work BTW. If not true please advise.