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 - FileNotFoundError: [Errno 2] No such file or directory when filename contains unusual symbols #86

Open
JohnDiGriz opened this issue Apr 23, 2023 · 3 comments

Comments

@JohnDiGriz
Copy link

I have this exception

Traceback (most recent call last):
  File "/run/media/johndigriz/Transcend/Itchiodl/itchiodl-fix-no-hash/itchiodl/library.py", line 108, in download_library
    for _ in r:
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/run/media/johndigriz/Transcend/Itchiodl/itchiodl-fix-no-hash/itchiodl/library.py", line 99, in dl
    g.download(self.login, platform)
  File "/run/media/johndigriz/Transcend/Itchiodl/itchiodl-fix-no-hash/itchiodl/game.py", line 99, in download
    self.do_download(d, token)
  File "/run/media/johndigriz/Transcend/Itchiodl/itchiodl-fix-no-hash/itchiodl/game.py", line 232, in do_download
    if utils.md5sum(out_file) != d["md5_hash"]:
  File "/run/media/johndigriz/Transcend/Itchiodl/itchiodl-fix-no-hash/itchiodl/utils.py", line 54, in md5sum
    with path.open("rb") as f:
  File "/usr/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: 'darkjaguar8/a-fairys-day-adventure/A Fairy’s Day Adventure into the Human World.pdf'

The error happens with files that contain any non-English letters, a single quote and some other symbols

@ForestFeather
Copy link

Coming to say I've hit this as well recently.

@undeadrattler
Copy link

undeadrattler commented Jun 10, 2023

Friend and I found a temporary fix by setting whatever your environment is to UTF-8, copying the mangled file to the correct name, and adjusting utils.py to have the MD5 check section updated as follows:

    """Returns the md5sum of a file"""
    md5 = hashlib.md5()
    #with path.open("rb") as f:
    with open(path, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            md5.update(chunk)
    return md5.hexdigest()

TheFrenchGhosty added a commit to TheFrenchGhosty/itchio-fixed that referenced this issue Apr 15, 2024
@TheFrenchGhosty
Copy link

@undeadrattler Seems to work thanks, I really wonder why it doesn't download in the correct encoding format... it just dies if a filename has a apostrophe...

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

4 participants