pytr icon indicating copy to clipboard operation
pytr copied to clipboard

OSError: [Errno 63] File name too long

Open bluefish007 opened this issue 7 months ago • 3 comments

I get the following error: OSError: [Errno 63] File name too long:

The problem is with old documents from 2020, where the doc_id is part of the filename (at least for one document in my case) and is written again in parentheses after it in line 136 in dl.py: filename_with_doc_id = filename + “f” ({doc_id})”

This makes the filename too long!

Possible fix for line 136 in dl.py:

if filename.endswith(doc_id):
    filename_without_id = filename[:-len(doc_id)].rstrip()
    filename_with_doc_id = filename_without_id + f" ({doc_id})"
else:
    filename_with_doc_id = filename + f" ({doc_id})"

bluefish007 avatar May 01 '25 11:05 bluefish007

Wouldn't it be enough to just use:

if filename.endswith(doc_id):
    filename_with_doc_id = filename
else:
    filename_with_doc_id = filename + f" ({doc_id})"

?

RealCLanger avatar May 01 '25 20:05 RealCLanger

Yes, that would also be possible, but then you would have “filename doc_id.pdf” and “filename (doc_id).pdf”

I think it would be nicer if it was always the same, i.e. always in brackets, therefore my suggestion.

bluefish007 avatar May 02 '25 11:05 bluefish007

OK, understood. I added the code to PR #223.

RealCLanger avatar May 31 '25 07:05 RealCLanger

Since the changes for the PR were merged and a new version released (v0.4.3) I'm closing this issue as resolved. Please let me know if there's still a problem with that fix.

RealCLanger avatar Jul 20 '25 06:07 RealCLanger