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

OSError: [Errno 36] File name too long while looking for sidecar files #24

Open
mgedmin opened this issue Sep 1, 2024 · 0 comments · May be fixed by #25
Open

OSError: [Errno 36] File name too long while looking for sidecar files #24

mgedmin opened this issue Sep 1, 2024 · 0 comments · May be fixed by #25

Comments

@mgedmin
Copy link

mgedmin commented Sep 1, 2024

I have some stories from online magazines saved on disk using a browser's Save As: Web page (complete) feature, which stores all the resources (CSS, images, JS) in a subdirectory and rewrites the HTML to link to those.

lib2opds 0.1.2 failed while trying to process one of these with a

Traceback (most recent call last):
  File "/home/mg/.local/bin/lib2opds", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/app.py", line 81, in cli
    opds_catalog = lib2odps(config, config.library_dir)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/opds.py", line 279, in lib2odps
    feed_by_directory = dir2odps(config, config.library_dir, feed_root, feed_root)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/opds.py", line 67, in dir2odps
    dir_feed: NavigationFeed | AcquisitionFeed = dir2odps(
                                                 ^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/opds.py", line 67, in dir2odps
    dir_feed: NavigationFeed | AcquisitionFeed = dir2odps(
                                                 ^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/opds.py", line 67, in dir2odps
    dir_feed: NavigationFeed | AcquisitionFeed = dir2odps(
                                                 ^^^^^^^^^
  [Previous line repeated 2 more times]
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/opds.py", line 84, in dir2odps
    p.load_metadata()
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/publications.py", line 153, in load_metadata
    self._load_metadata_from_sidecar_files(self.fpath)
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/publications.py", line 121, in _load_metadata_from_sidecar_files
    if not self._load_metadata_from_sidecar_file(get_metadata_sidecar_file(fpath)):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/publications.py", line 82, in _load_metadata_from_sidecar_file
    if not sidecar.read():
           ^^^^^^^^^^^^^^
  File "/home/mg/.local/pipx/venvs/lib2opds/lib/python3.12/site-packages/lib2opds/sidecars.py", line 69, in read
    if not self.fpath.is_file():
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 894, in is_file
    return S_ISREG(self.stat().st_mode)
                   ^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 842, in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: 'scifi/Premee Mohamed/More Tomorrow (short story)/raw/More Tomorrow—Premee Mohamed — Automata_files/migXv4fDOuVrUJ1bRkfR6Zommvc_ywWY9tlq3FI62lSfeGC2fFHN4UJLFRbh52jhWD9o5eIkFDS3ZRbDjR9u5Q6UZRqXFhI3jy78MPG0-cNGdKucdY80d18zScClZ1FGjkoDSWmyScmDSeBRZPoRdhXCjWmXdhuyieBkZWZTZWS0jhNlOeTz-etlZcUodcooda4nOAZD-ew0SaBujW48Sagyjh90jhNlOeUzjhBC-eNDifUaiaS0jWmXdhuy.info'

This file does not exist, but there is a migXv4fDOuVrUJ1bRkfR6Zommvc_ywWY9tlq3FI62lSfeGC2fFHN4UJLFRbh52jhWD9o5eIkFDS3ZRbDjR9u5Q6UZRqXFhI3jy78MPG0-cNGdKucdY80d18zScClZ1FGjkoDSWmyScmDSeBRZPoRdhXCjWmXdhuyieBkZWZTZWS0jhNlOeTz-etlZcUodcooda4nOAZD-ew0SaBujW48Sagyjh90jhNlOeUzjhBC-eNDifUaiaS0jWmXdhuy.js in that directory.

mgedmin added a commit to mgedmin/lib2opds that referenced this issue Sep 15, 2024
Sometimes there are files on disk that barely fit within file name
length limits, so when we construct new filenames by appending extra
suffixes like .info, we might hit these file name length limits.

Fixes oxdef#24.
@mgedmin mgedmin linked a pull request Sep 15, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant