Skip to content

Conversation

@psrok1
Copy link
Member

@psrok1 psrok1 commented Dec 19, 2025

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the new behaviour?

Alternative password can be set in MWDB configuration for files downloaded as zip. The default is "infected".

Closing issues

closes #1092

@psrok1 psrok1 marked this pull request as draft December 19, 2025 17:28
with aes_zipf.open(self.file_name, mode="w") as fdst:
fsrc = self.open()
try:
shutil.copyfileobj(fsrc, fdst)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can lower memory footprint here I think:

if self.upload_stream is not None:
    self.upload_stream.seek(0)
    for chunk in iter(lambda: self.upload_stream.read(chunk_size), b""):
        zipf.write(chunk)
else:
    with self.open() as fsrc:
        for chunk in iter(lambda: fsrc.read(chunk_size), b""):
            zipf.write(chunk)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil.copyfileobj does exactly that (copying in chunks): https://github.com/python/cpython/blob/main/Lib/shutil.py#L249

@yankovs
Copy link
Contributor

yankovs commented Dec 20, 2025

what do you mean by "on the fly"?

@psrok1 psrok1 force-pushed the feature/zip-file-improvements branch from 51cff3c to cb27526 Compare January 12, 2026 16:52
@psrok1 psrok1 changed the title File.zip_file: don't load contents into memory while zipping, support custom password File.zip_file: support custom password Jan 12, 2026
@psrok1
Copy link
Member Author

psrok1 commented Jan 12, 2026

Memory usage improvements have been implemented here: #1108

By "on the fly" I mean zipping file in chunks and sending the zipped part as soon as possible, without waiting for a whole file to be compressed.

@psrok1 psrok1 marked this pull request as ready for review January 12, 2026 17:10
@psrok1 psrok1 merged commit 5b43882 into master Jan 12, 2026
13 checks passed
@psrok1 psrok1 deleted the feature/zip-file-improvements branch January 12, 2026 17:18
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 this pull request may close these issues.

Download encrypted zipped file with different password(not the default "infected")

3 participants