Skip to content

Body download of multipart yEnc files makes them corrupt #99

@Bjarke42

Description

@Bjarke42

If you use body to retrieve several parts that are yEnc encoded they are always corrupt. Sometimes you can retrieve a one part file the is not corrupt.

So i tried to solve this and came up with this mockup of body:

import sabctools

#other code here

def body(
        self,
        msgid_article: str | int | None = None,
        #decode: bool | None = None,
    ) -> bytes:
        
        args = None
        if msgid_article is not None:
            args = str(msgid_article)

        code, message = self.command("BODY", args)
        if code != 222:
            raise NNTPReplyError(code, message)
        
        # _body code
        data_plain: bytes = b""
        for line in self._info(code, message):
            data_plain+=bytes(line)
        
        
        
        (
        	decoded_data,
        	yenc_filename,
        	file_size,
        	data_begin,
        	data_size,
        	crc_correct,
    	) = sabctools.yenc_decode(memoryview(bytes(data_plain)))
        
        #if crc_correct is None:
            #self.logging.info("CRC Error in %s", article.article)
            #raise BadData(decoded_data)
        return decoded_data,yenc_filename,file_size,data_begin,data_size,crc_correct

So here i used sabctools yEnc decoder and it works, also its 10x faster!

This makes it possible to actually use body for retrieveing files.

And as a hint to how i did it, i first use group, then body to retrieve my headers.

I have not been sucessfully in using their highspeed variables, so this version is without any corruption of data and uses plain normal python variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions