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

cleanup ftp publisher code #64

Merged
merged 1 commit into from
Jan 21, 2022
Merged

Conversation

b3n4kh
Copy link
Contributor

@b3n4kh b3n4kh commented Jan 21, 2022

allow well formated uris
throw error on wrong scheme

allow well formated uris
throw error on wrong scheme
except Exception as error:
BasePublisher.print_exception(self, error)
finally:
os.remove(filename)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Initially I thought finally is not a good place for os.remove(), because it wipes the file even if the upload was not successful. That's why in the original version it was inline, and also the reason why someone thought temporary local file names should be predictable (to allow troubleshooting).

However on the other read of our code, we should probably handle this better upstream, and also prevent a race condition with naming at the same time. I'll open an issue for that, and accept this code so the failed uploads don't clutter the container forever.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or use else: in the try-except clause

Copy link
Collaborator

Choose a reason for hiding this comment

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

we could have just left it as it was, but I like this approach, followed by more cleanup which I propose in #66

Copy link
Collaborator

@milankowww milankowww left a comment

Choose a reason for hiding this comment

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

thank you for the contribution

@milankowww milankowww merged commit 79df70a into SK-CERT:main Jan 21, 2022
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.

3 participants