gotify / gotify/server

Application image may not be cleaned up with concurrent uploads

Open
#1,047 0 comments 0 reactions 0 assignees View on GitHub
a:bug
Dominant language
Go
Stars
15.9k
Forks
873
Avg merge
2d 22h
Merged PRs (30d)
6

Description

When concurrently uploading new images for the same application, it's possible that the old image isn't deleted correctly.

UploadApplicationImage reads the current app image, saves the new file, deletes the old file, and then updates the database. When two uploads for the same application run concurrently, both read the same old image name and both delete it. Only the last database update will be applied. The file written by the other request stays on disk but is no longer referenced by any application.

Reported privately by @ry2811

Contributor guide

Open the contributing guide

Research direction

Start at the UploadApplicationImage entry point and trace how concurrent uploads read the current image, write files, delete the old file, and update the database. Reproduce two uploads for one application concurrently; done means the database references the final image and no unreferenced uploaded file remains on disk.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.