campeon23 / split-fetcher

The code is a concurrent file downloader in Go that splits a file into multiple parts, downloads them in parallel, and assembles the final file, with support for Etag validation to ensure file integrity.
MIT License
1 stars 0 forks source link

Refactor File Encryption and Manifest Logic #162

Closed campeon23 closed 1 year ago

campeon23 commented 1 year ago

Description: There's a need to enhance the current logic around file encryption and manifest handling. The following tasks need to be addressed:

  • Remove the File Utils Initializer from the EncryptFile() method. This adjustment will help the unit test to not panic since some parameters passed to the Initializer are null.
  • In accordance with Go naming conventions, rename the GetDownloadManifestPath() to ManifestPath(). This will eliminate redundancy and make the function naming more intuitive.
  • Make necessary corrections in the manifest_test.go to align with the refactored manifest.go logic. This is crucial since manifests are now encrypted in memory and subsequently saved to disk, rather than directly created on the disk.

Acceptance Criteria:

  • The EncryptFile() method should operate without the File Utils Initializer and the unit tests should pass without panics.
  • The function GetDownloadManifestPath() should be successfully renamed to ManifestPath() and all its references updated throughout the codebase.
  • The manifest_test.go should be updated to reflect the new logic in manifest.go. Unit tests must pass successfully, ensuring that the manifests are encrypted in memory and saved to the disk as expected.

Notes: The refactoring of this logic is essential for the stability and maintainability of the encryption and manifest handling features in our application. Proper code documentation is expected for all changes.

Severity Level: Medium

campeon23 commented 1 year ago

The necessary enhancements and refactoring have been successfully implemented:

The File Utils Initializer has been removed from the EncryptFile() method. This change has improved the stability of our unit tests by preventing panics caused by null parameters.

For clearer code readability and to abide by Go naming conventions, the function GetDownloadManifestPath() has been renamed to ManifestPath().

I've also made significant updates to manifest_test.go to ensure its compatibility with the changes in manifest.go. As a result, manifests are now initially encrypted in memory before being saved to disk, marking a departure from the previous approach where they were created directly on the disk.

With these modifications in place, I believe this ticket can be confidently closed. All related unit tests have passed successfully, and the system's performance remains optimal.