Skip to content

fix: delete uploaded temp file after processing in syllabus upload route - #680

Open
khushikakade wants to merge 1 commit into
lovelymahor:mainfrom
khushikakade:fix/feedback-routes-require-path
Open

fix: delete uploaded temp file after processing in syllabus upload route#680
khushikakade wants to merge 1 commit into
lovelymahor:mainfrom
khushikakade:fix/feedback-routes-require-path

Conversation

@khushikakade

Copy link
Copy Markdown

Summary

Fixes #679

Uploaded files processed by POST /api/syllabus/upload were never
deleted from disk after the route finished (on either success or failure
paths). This caused:

  • Unbounded disk growth over time
  • User-uploaded files being permanently retained beyond their intended
    processing window
  • Files remaining publicly accessible via GET /uploads/<filename>
    since the uploads directory is served as static

Changes Made

Added a finally block to fs.unlink() the Multer temp file after
every request, regardless of outcome:

} finally {
  if (req.file && req.file.path) {
    fs.unlink(req.file.path, (err) => {
      if (err) console.error('Failed to delete uploaded temp file:', err);
    });
  }
}

Uploaded files in /api/syllabus/upload were never removed from disk
after processing, causing unbounded storage growth and leaving user files
permanently accessible via the static /uploads route.

Added a finally block to fs.unlink() the temp file on every request
path — both successful responses and error cases.

Fixes lovelymahor#679
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

@khushikakade is attempting to deploy a commit to the Lovely Mahour's projects Team on Vercel.

A member of the Team first needs to authorize it.

@khushikakade

Copy link
Copy Markdown
Author

I've submitted the fix. Let me know if you need anything else! I see the Vercel check needs maintainer authorization to run the preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Uploaded files in /api/syllabus/upload are never deleted from disk — causes unbounded storage growth and file retention risk

1 participant