Skip to content

Commit 772c3d2

Browse files
committed
Refactor ChecksumValidation as UploadInterceptor plugin
- Convert from monkey-patching to clean plugin architecture - Break down monolithic upload handler into focused functions - Use onUploadComplete hook instead of direct status observers - Move ChecksumValidation.js to plugin folder structure - Remove direct UploaderModel prototype manipulation - Maintain all existing checksum generation and validation functionality
1 parent 82ebe36 commit 772c3d2

File tree

6 files changed

+266
-278
lines changed

6 files changed

+266
-278
lines changed

src/js/core/ChecksumValidation.js

Lines changed: 0 additions & 272 deletions
This file was deleted.

src/js/core/UploadInterceptor/UploadInterceptor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class UploadInterceptor {
6666
return;
6767
}
6868

69+
this.isPatched = true; // Set immediately to prevent double calls
70+
6971
// Wait for UploaderModel to be available
7072
this.waitForUploaderModel().then(() => {
7173
this.applyUploadPatch();
@@ -92,7 +94,6 @@ class UploadInterceptor {
9294
// Override the uploadPresigned method
9395
UploaderModel.UploadItem.prototype.uploadPresigned = this.createPatchedUploadMethod();
9496

95-
this.isPatched = true;
9697
console.log('UploadInterceptor: Successfully patched upload system');
9798
}
9899

src/js/core/UploadInterceptor/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
*/
77

88
import UploadInterceptor from './UploadInterceptor.js';
9+
import ChecksumValidationPlugin from './plugins/ChecksumValidation/ChecksumValidation.js';
910
import UploadVolumeChecker from './plugins/UploadVolumeChecker/UploadVolumeChecker.js';
1011

1112
// Initialize the upload interceptor system when DOM loads
1213
window.addEventListener("load", () => {
1314
console.log('UploadInterceptor: Initializing upload interception system');
1415

1516
// Register plugins
17+
UploadInterceptor.register(ChecksumValidationPlugin);
1618
UploadInterceptor.register(UploadVolumeChecker);
1719

18-
// Note: ChecksumValidation plugin will be registered here after refactoring
19-
2020
console.log('UploadInterceptor: System initialized with plugins:', UploadInterceptor.getRegisteredPlugins());
2121
});
2222

0 commit comments

Comments
 (0)