odmpy icon indicating copy to clipboard operation
odmpy copied to clipboard

OSError: [Errno 36] File name too long

Open ahxxm opened this issue 9 months ago • 1 comments

Problem and Reproduce

In rare cases, e.g. Lonely Planet series, there might be more than 10 authors, making the filename exceed limit of ext4

Lonely Planet Great Britain - Kerry Walker, Lauren Keith, Emily Luxton, Hugh McNaughtan, Lorna Parkes, Joseph Reaney, Tasmin Waby, Neil Wilson, Isabel Albiston, Oliver Berry, Joe Bindloss, Keith Drew, Dan Fahey, Kay Gillespie, Laurie Goodlad, Sarah Irving.epub

Version/Environment

latest master, regular linux

Workaround

In extract_authors_from_openbook, remove the last ones by

def extract_authors_from_openbook(openbook: Dict) -> List[str]:
    """
    Extract list of author names from openbook

    :param openbook:
    :return:
    """
    creators = [
        c["name"]
        for c in openbook.get("creator", []) if c.get("role", "") in {"author", "editor"}
    ]
    while len(", ".join(creators)) > 100:  # 100 is arbitrary
        creators.pop()
    return creators

ahxxm avatar May 04 '24 03:05 ahxxm