Skip to content

fix: automatic disk cleanup on upload and document deletion - #3

Merged
sharadcodes merged 2 commits into
devfrom
bugfix/delete-cleanup
Jul 8, 2026
Merged

fix: automatic disk cleanup on upload and document deletion#3
sharadcodes merged 2 commits into
devfrom
bugfix/delete-cleanup

Conversation

@sharadcodes

@sharadcodes sharadcodes commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a disk space leak where uploaded source files and generated audio files were left on disk after document deletion.

Changes

Upload Temporary File Cleanup

  • Wraps the upload processing in a try/finally block
  • Immediately deletes the original uploaded file (.epub/.txt) and any intermediate Calibre-extracted .extracted.txt file from /data/uploads/ after text import
  • If the import fails at any stage, also cleans up the cover image target to prevent orphan files

Document Deletion Disk Cleanup

  • delete_document now accepts Settings and queries all associated Job IDs before deleting DB rows
  • After DB deletion, unlinks the cover image file from /data/uploads/
  • Recursively deletes the generated audio directory /data/audio/<job_id>/ for all associated jobs (MP3, WAV chunks)

Tests

Added tests/test_api_cleanup.py with an integration test that verifies:

  1. After upload: temporary source file is deleted, only cover image remains in /data/uploads/
  2. After document delete: cover image is unlinked, all generated job audio directories are removed from disk

All 48 tests pass. ✅

@sharadcodes sharadcodes added the bug Something isn't working label Jul 8, 2026
@sharadcodes sharadcodes added this to Awaaz Jul 8, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Awaaz Jul 8, 2026
@sharadcodes sharadcodes moved this from Backlog to Done in Awaaz Jul 8, 2026
@sharadcodes
sharadcodes merged commit 59239ce into dev Jul 8, 2026
3 checks passed
@sharadcodes sharadcodes mentioned this pull request Jul 8, 2026
@sharadcodes
sharadcodes deleted the bugfix/delete-cleanup branch July 8, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant