Skip to content

[BE-151] documents.service.ts: upload() leaves an orphaned file on disk if the database insert fails #1539

Closed

Description

@mftee

DocumentsService.upload() computes the SHA-256 of the already-multer-written file, then calls documentRepo.save(doc). If that save throws (constraint violation, connection loss, etc.) after Multer has already written the file to UPLOAD_DIR, there is no catch/cleanup path that deletes the orphaned file — unlike delete(), which does call fs.unlinkSync. Over time this leaks disk space with files that have no corresponding Document row.

Activity

  1. Luna-netty commented on Sep 25, 2026

    @Luna-netty

    @Luna-netty has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi maintainer, I have read and understood the issue requirements and checked the necessary documentation. I’m confident I can work on this task effectively and deliver a proper solution.
    Happy to discuss the approach first if that's useful before I start.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Luna-netty to this issue.

  2. Hassan-oladipupo commented on Sep 25, 2026

    @Hassan-oladipupo
    Contributor

    @Hassan-oladipupo has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi, I'd like to work on this issue.

    I'm an experienced software engineer with a strong foundation in JavaScript/TypeScript, distributed systems, and API development. I care about code quality, test coverage, and clear communication in open source work.

    I've gone through the details of this issue and I'm confident I can deliver a clean, well-tested solution that fits the codebase.

    Please assign this issue to me, I'd be happy to contribute.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Hassan-oladipupo to this issue.

  3. drips-wave commented on Sep 25, 2026

    @drips-wave

    Congratulations, @Hassan-oladipupo! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @Hassan-oladipupo: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  4. added a commit that references this issue on Sep 25, 2026
    09c2afb
  5. grantfox-oss commented on Sep 25, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @Hassan-oladipupo's PR #1616 was approved and merged by @mftee.

    🏆 @Hassan-oladipupo: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (672 total points). Track your full progress on GrantFox.

    👏 Great work, @Hassan-oladipupo! Keep contributing to CodeGirlsInc.

  6. drips-wave commented on Sep 25, 2026

    @drips-wave

    This issue has been completed by @Hassan-oladipupo as part of the Stellar Wave Program's 9th Wave 🥳

    😎 @Hassan-oladipupo: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions