-
Notifications
You must be signed in to change notification settings - Fork 16
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
Mail Filesize/Filename Fixer Script #46
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before the script tries to find files in the directory, it now checks if the directory exists and is readable. If the directory does not exist or is not readable, the script will print an error message and exit with status 1.
I added a sanitize_filename function that removes potentially harmful characters from the filename. This function is called to sanitize the filename before it’s used in the check_and_fix function.
In this version, the check_and_fix function has been split into three separate functions: check_filenames, export_mismatches, and fix_mismatches. The check_filenames function is always run, and the export_mismatches and fix_mismatches functions are run if the corresponding flags are set. This makes the script more modular and easier to understand and maintain.
The check_filenames function stores the mismatch information in an array called mismatches. Each element of the array is a string containing the filename, expected size, and actual size, separated by commas. The export_mismatches and fix_mismatches functions then iterate over this array to perform their respective actions. This allows the script to remember the mismatches found during the initial check and use this information later if the user decides to fix or export the mismatches.
Removed the sanitize_filename function, as the risk of filename manipulation is negligible
Commas are used in the filenames
sibprogrammer
approved these changes
Jan 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces the Mail Filesize/Filename Fixer script I coded. The script validates and corrects discrepancies between actual and reported file sizes in mail files.
There was an earlier draft (not present in this repo).
Improvements include better handling of file size discrepancies and options to fix these discrepancies by renaming the files or exporting the mismatched filenames to a text file.
For more details on usage, requirements and functionality of the updated script, please see the README.md in this pull request.