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

Error when saving attachment with a customPath #322

Closed
1 of 2 tasks
programmarchy opened this issue Jan 12, 2023 · 4 comments
Closed
1 of 2 tasks

Error when saving attachment with a customPath #322

programmarchy opened this issue Jan 12, 2023 · 4 comments

Comments

@programmarchy
Copy link
Contributor

Bug Metadata

  • Version of extract_msg: 0.38.4
  • Your python version: Python 3.9.14
  • How did you launch extract_msg?
    • My command line or
    • I used the extract_msg package

Describe the bug
When using a customPath in attachment.save an UnboundLocalError exception may be thrown.

**What code did you use or can we use to reproduce this error?

msg = extract_msg.Message(file_path)
for attachment in msg.attachments:
  attachment.save(customPath=output_path)

Traceback

Traceback (most recent call last):
  File "/home/user/project/process_msg_emails.py", line 46, in <module>
    extract_msg_file(file_path, output_path)
  File "/home/user/project/process_msg_files.py", line 30, in extract_msg_file
    attachment.save(customPath=output_path)
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/attachment.py", line 232, in save
    if createdZip:
UnboundLocalError: local variable 'createdZip' referenced before assignment

Additional context

A similar pattern exists in message_base.py and signed_attachment.py

@TheElementalOfDestruction
Copy link
Collaborator

TheElementalOfDestruction commented Jan 12, 2023

Actually that's a bug in the unreleased version, lol, but I'll fix that real quick. I was wondering why I had a redundant check, but now I know

It should happen regardless of custom path being set, in fact

@programmarchy
Copy link
Contributor Author

Ah okay. When I was testing for #321 I was probably seeing other work that's not done yet.

I also found an issue with headerFormatProperties in contact.py:

programmarchy@4950a3a

Are you still working on this also or would you want me to create an issue + PR?

@TheElementalOfDestruction
Copy link
Collaborator

No such issue should be present with signed attachment (it has the proper check of if _zip and createdZip. _zip being set means createdZip will be set. This is now fixed.

@TheElementalOfDestruction
Copy link
Collaborator

Ah okay. When I was testing for #321 I was probably seeing other work that's not done yet.

I also found an issue with headerFormatProperties in contact.py:

programmarchy@4950a3a

Are you still working on this also or would you want me to create an issue + PR?

This needs an issue and pr

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

No branches or pull requests

2 participants