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

Remove Non-Zip File from SFTP Sever #176

Merged
merged 2 commits into from
Sep 27, 2024
Merged

Remove Non-Zip File from SFTP Sever #176

merged 2 commits into from
Sep 27, 2024

Conversation

pluckyswan
Copy link
Contributor

@pluckyswan pluckyswan commented Sep 27, 2024

Remove Non-Zip File from SFTP Sever

Description

Refactored copySingleFile to prevent early returning for a non-zip file when removing file from sftp server. Updated docker-compose to have consistent starting directory for sftp server. Tested locally to ensure that non-zip is ingested and deleted.

Issue

CDCgov/trusted-intermediary#1337

Checklist

  • I have added tests to cover my changes

Note: You may remove items that are not applicable

…f a non-zip file

Co-authored-by: saquino0827 <saquino@flexion.us>
Co-authored-by: James Herr <jherr@flexion.us>
Co-authored-by: jcrichlake <145698165+jcrichlake@users.noreply.github.com>
Co-authored-by: Sylvie <sschuresko@flexion.us>
Co-authored-by: saquino0827 <saquino@flexion.us>
Co-authored-by: James Herr <jherr@flexion.us>
Co-authored-by: jcrichlake <145698165+jcrichlake@users.noreply.github.com>
Co-authored-by: Sylvie <sschuresko@flexion.us>
Copy link

sonarcloud bot commented Sep 27, 2024

@pluckyswan pluckyswan merged commit a5d878d into main Sep 27, 2024
13 checks passed
@pluckyswan pluckyswan deleted the delete-non-zip-file branch September 27, 2024 17:37
@pluckyswan
Copy link
Contributor Author

/review

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling
The error handling in the new code does not propagate errors up the call stack, which might suppress important error information and make debugging difficult.

if err != nil {
slog.Error("Failed to remove file from local server", slog.Any(utils.ErrorKey, err), slog.String("name", fileInfo.Name()))
//delete file from local filesystem
err = os.Remove(fileInfo.Name())

Choose a reason for hiding this comment

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

Consider adding a defer statement to handle file cleanup in a more reliable way. This ensures that the file is always removed regardless of where the function exits due to an error. [important]

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