Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when a game file changes name when downloaded due to filename character restrictions #74

Open
dph121 opened this issue Mar 17, 2023 · 2 comments

Comments

@dph121
Copy link

dph121 commented Mar 17, 2023

One of the files in the game https://ladyorthetiger.itch.io/platonic-pirates is named Platonic Pirates — Light.pdf. When I run the program, either as a complete library download or downloading just the game, the file is stored on my computer as Platonic Pirates â�� Light.pdf, after which the program crashes with the following dialogue:

(base) C:\Daphne\itchio>python -m itchiodl.downloader -k REDACTED --download-game https://ladyorthetiger.itch.io/platonic-pirates
platonic-pirates is a purchased game.
Loading page 1
Downloading Platonic Pirates
Downloading Platonic Pirates — Light.pdf
Downloading Platonic Pirates - Platonic Pirates — Light.pdf
Downloaded Platonic Pirates â Light.pdf
Traceback (most recent call last):
File "C:\Users\flipw\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\flipw\anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\downloader_main
.py", line 66, in
main()
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\downloader_main
.py", line 62, in main
lib.download_library(args.platform)
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\library.py", line 108, in download_library
for _ in r:
File "C:\Users\flipw\anaconda3\lib\concurrent\futures_base.py", line 609, in result_iterator
yield fs.pop().result()
File "C:\Users\flipw\anaconda3\lib\concurrent\futures_base.py", line 446, in result
return self.__get_result()
File "C:\Users\flipw\anaconda3\lib\concurrent\futures_base.py", line 391, in __get_result
raise self._exception
File "C:\Users\flipw\anaconda3\lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\library.py", line 99, in dl
g.download(self.login, platform)
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\game.py", line 75, in download
self.do_download(d, token)
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\game.py", line 187, in do_download
if utils.md5sum(out_file) != d["md5_hash"]:
File "C:\Users\flipw\anaconda3\lib\site-packages\itchiodl\utils.py", line 51, in md5sum
with path.open("rb") as f:
File "C:\Users\flipw\anaconda3\lib\pathlib.py", line 1252, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "C:\Users\flipw\anaconda3\lib\pathlib.py", line 1120, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'ladyorthetiger\platonic-pirates\Platonic Pirates — Light.pdf'

My bughunt lead me to line 95 in game.py producing an "output filename" string that doesn't match what the actual filename is in the output folder. This results in line 99 assuming a file has not been downloaded, and line 187 crashing the program by trying to determine a checksum of a file that does not exist.

This is on Windows 11, so the specific filename replacement might not be reproduced on other machines. I am capable of downloading many other files.

@Emersont1
Copy link
Owner

Emersont1 commented Mar 17, 2023 via email

@N64Core
Copy link
Contributor

N64Core commented Mar 21, 2023

Hi!

I believe I have a fix for smeared unicode characters in this branch here: N64Core@7c7a70d

I only hazily remember what the issue is, I believe it has something to do with how the = operator and unicode strings interact, but it's been several months.

Once my existing PR gets merged in I can submit it upstream

Edit: Confirmed that title generates the filename correctly on that branch:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants