feat(server): add automatic cleanup of upload files older than 24 hours#47
Open
abhishekmanegit wants to merge 1 commit into
Open
feat(server): add automatic cleanup of upload files older than 24 hours#47abhishekmanegit wants to merge 1 commit into
abhishekmanegit wants to merge 1 commit into
Conversation
|
@abhishekmanegit is attempting to deploy a commit to the Pushkarini 's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or 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
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.
What this PR does
Implements automatic cleanup of uploaded retina scan files to prevent disk exhaustion on the server, as requested in #37.
The
server/uploads/directory accumulates every uploaded scan with no removal mechanism. This PR adds a scheduled background task that automatically deletes files older than 24 hours.Changes
node-cronas a dependency (server/package.json)server/utils/cleanupUploads.jsserver/uploads/directorymtimeMs)server/index.jsnode-cronand the new cleanup utility0 * * * *)How it works
Every hour, the cron job iterates through all files in
uploads/, compares each file's age against the 24-hour threshold, and removes any file that exceeds it usingfs.unlink.Testing
Tested locally by temporarily lowering the threshold to 10 seconds and the cron schedule to every 15 seconds:
node index.js)server/uploads/🧹 Running scheduled uploads cleanup...
🗑️ Cleanup: deleted old file testfile.txt
4. Verified the file was removed from the
uploads/folder5. Reverted the threshold and schedule back to production values (24 hours / hourly) before committing
Notes
Closes #37