Skip to content

feat(cleanup): add stale chunked upload cleanup worker#208

Open
onkar0127 wants to merge 1 commit into
imanchalsingh:mainfrom
onkar0127:feat/upload-cleanup-worker
Open

feat(cleanup): add stale chunked upload cleanup worker#208
onkar0127 wants to merge 1 commit into
imanchalsingh:mainfrom
onkar0127:feat/upload-cleanup-worker

Conversation

@onkar0127

@onkar0127 onkar0127 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

fixes #113


Feature: Automated Background Cleanup Worker for Abandoned Chunked Uploads

1. Description

Implements an automated cleanup system for incomplete/abandoned chunked file uploads to resolve local disk leaks and database clutter. It tracks file status, hides incomplete uploads from the dashboard, and runs a daily cron job at midnight to delete abandoned uploads older than 24 hours.

2. Key Changes

  • Database Fields: Added a status field ('PENDING' | 'COMPLETED') to File and a fileId reference to UploadSession.
  • Upload Flow: initUpload pre-creates the File document in PENDING state; saveFileInfo updates and promotes it to COMPLETED.
  • Query Exclusions: Excluded PENDING files from stats, favorites, tag lookups, global search, and folder listings.
  • Background Worker: Added a daily midnight cron job (0 0 * * *) to cascade-delete stale pending files, upload sessions, and local disk folders.
  • Bug Fixes: Declared the missing next parameter in uploadController.js endpoints to resolve potential crash loops, and added queue bypasses for tests when running without Redis.

- Track upload status (PENDING / COMPLETED) in File model schema
- Link UploadSession to File model using fileId
- Pre-create PENDING file in initUpload and promote to COMPLETED in saveFileInfo
- Exclude PENDING files from listings, folder retrieval, tag retrieval, and statistics
- Add a background cron job scheduled daily at midnight to sweep stale PENDING uploads
- Support disabling queues via environment variables to prevent test lockups
@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

👷 Deploy request for file-sharingsystem pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9c8e9d0

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@onkar0127 is attempting to deploy a commit to the imanchalsingh Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added SSoC26 Official label of org backend labels Jul 1, 2026
@onkar0127

Copy link
Copy Markdown
Contributor Author

@imanchalsingh can you please checkout My PR!!

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

Labels

backend SSoC26 Official label of org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Automated Cleanup Worker for Abandoned/Stale Chunked Uploads

1 participant