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

Absolute path in --dirname-pattern fails on linux #186

Open
catthou opened this issue Apr 24, 2023 · 0 comments
Open

Absolute path in --dirname-pattern fails on linux #186

catthou opened this issue Apr 24, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@catthou
Copy link

catthou commented Apr 24, 2023

Version

Version: 2022-04-28

Your Command

Two particular commands fail.

python3 /home/catthou/.sys/apps/kemono-dl/kemono-dl.py --extract-links --dirname-pattern '/b/asteroid/kemono-dl/{service}/{username} [{user_id}]' --from-file '/home/catthou/Development/downloads/default.kemono-dl' --cookies '/home/catthou/bin/kemono/kemono.party_cookies.txt'

The above command fails to write the file into /b/... and instead writes it into {current directory}/b/...

Next we try to cd into the root directory so {current directory}/b is /b, but this fails for a different reason:

cd / && python3 /home/catthou/.sys/apps/kemono-dl/kemono-dl.py --extract-links --dirname-pattern '/b/asteroid/kemono-dl/{service}/{username} [{user_id}]' --from-file '/home/catthou/Development/downloads/default.kemono-dl' --cookies '/home/catthou/bin/kemono/kemono.party_cookies.txt'

Description of bug

The first command simply tries to reference /b (folder 'b' in the root directory of the OS). It fails because the directory you run kemono-dl from is ALWAYS appended to the front, so /b becomes {current directory}/b instead of root-directory/b.

The second command fails because kemono-dl tries to write debug.log in {current directory}.

Error messages and tracebacks

Off the first command, there are no errors, per se. Files download, but into the wrong directory (into /home/catthou/b/... instead of /b/...)

Off the second command, we crash because we can't write the log file to the root directory:

Traceback (most recent call last):
  File "/home/catthou/.sys/apps/kemono-dl/kemono-dl.py", line 1, in <module>
    from src.main import main
  File "/home/catthou/.sys/apps/kemono-dl/src/main.py", line 15, in <module>
    from .logger import logger
  File "/home/catthou/.sys/apps/kemono-dl/src/logger.py", line 26, in <module>
    file_handler = logging.FileHandler('debug.log', encoding="utf-16")
  File "/usr/lib/python3.10/logging/__init__.py", line 1169, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.10/logging/__init__.py", line 1201, in _open
    return open_func(self.baseFilename, self.mode,
PermissionError: [Errno 13] Permission denied: '/debug.log'

Additional comments

Dumping a file with a non-descriptive filename (debug.log) in a random directory is bad practice to begin with. At the very least it should try typical log directories (like /var/log or $XDG_CACHE_HOME/kemono-dl) and use a name that indicates who's writing it. $XDG_CACHE_HOME/kemono-dl/debug.log or /var/log/kemono-dl.log would be two practical, expected filenames for logs on linux.

@catthou catthou added the bug Something isn't working label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant