-
Notifications
You must be signed in to change notification settings - Fork 13
#4941 - Approved exception does not repeat - Save File Hash #5017
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
#4941 - Approved exception does not repeat - Save File Hash #5017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds file hash storage functionality to the student file system to prevent duplicate exception file submissions. The implementation generates and stores SHA256 hashes of uploaded file content to enable future comparison for exception handling.
- Adds a new
file_hashcolumn to thestudent_filestable - Implements SHA256 hash generation during file upload
- Includes database migration scripts for adding and removing the column
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| student-file.model.ts | Adds optional fileHash property to the StudentFile entity |
| Add-file-hash-column.sql | Migration script to add the file_hash column to student_files table |
| Rollback-add-file-hash-column.sql | Rollback script to remove the file_hash column |
| AddStudentFileHash1754086479996.ts | TypeORM migration class that executes the SQL scripts |
| student-file.service.ts | Implements SHA256 hash calculation during file creation |
Comments suppressed due to low confidence (1)
sources/packages/backend/apps/db-migrations/src/migrations/1754086479996-AddStudentFileHash.ts:4
- The timestamp '1754086479996' represents a date in the year 2025 (August), which appears to be a future timestamp that may not be valid depending on when this migration needs to run.
export class AddStudentFileHash1754086479996 implements MigrationInterface {
sources/packages/backend/libs/sims-db/src/entities/student-file.model.ts
Show resolved
Hide resolved
| newFile.fileHash = createHash("sha256") | ||
| .update(createFile.fileContent) | ||
| .digest("hex"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if we consider the unique file name also when creating the file hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unique file name is exactly what we need to prevent to cause any change in the hash.
The idea here is to hash the file content only to allow the file content only verification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the intention now which follows the AC. Thanks for the sync up.
sources/packages/backend/libs/sims-db/src/entities/student-file.model.ts
Outdated
Show resolved
Hide resolved
sh16011993
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work @andrewsignori-aot 👍
sources/packages/backend/apps/api/src/services/student-file/student-file.service.ts
Show resolved
Hide resolved
| sims.student_files | ||
| ADD | ||
| COLUMN file_hash CHAR(64); | ||
| COLUMN file_hash CHAR(64) NOT NULL DEFAULT ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
dheepak-aot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start to the Hash. Looks good 👍




Saving the file hash for student-uploaded files to allow future comparison of exception files.
Migration rollback