Skip to content

Commit a13c58e

Browse files
authored
fix: enhance app icon download logic to include file existence check (#11796)
* fix: enhance app icon download logic to include file existence check - Updated the downloadAppIcon function to parse the icon field for the file name and ETag. - Added a condition to check if the icon file exists before setting the If-None-Match header for the request. * fix: improve app icon retrieval logic by adding filename check - Updated GetAppIcon method to include filename in the response. - Added a condition to ensure the ETag header is set only if both ETag and filename are present, enhancing the integrity of the caching mechanism.
1 parent 15d77ce commit a13c58e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

agent/app/api/v2/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (b *BaseApi) GetAppIcon(c *gin.Context) {
210210
helper.BadRequest(c, err)
211211
return
212212
}
213-
iconBytes, _, etag, err := appService.GetAppIcon(appKey)
213+
iconBytes, filename, etag, err := appService.GetAppIcon(appKey)
214214
if err != nil {
215215
helper.InternalServer(c, err)
216216
return
@@ -223,7 +223,7 @@ func (b *BaseApi) GetAppIcon(c *gin.Context) {
223223

224224
c.Header("Cache-Control", "public, max-age=2592000")
225225

226-
if etag != "" {
226+
if etag != "" && filename != "" {
227227
c.Header("ETag", etag)
228228
if c.GetHeader("If-None-Match") == etag {
229229
c.Status(http.StatusNotModified)

agent/app/service/app_sync_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ func (c *appSyncContext) syncAppIconsAndDetails() error {
221221
}
222222

223223
func (c *appSyncContext) downloadAppIcon(iconUrl, appKey, oldIcon string) (status int, iconField string) {
224-
existingEtag := appicon.GetETagFromIconField(oldIcon)
224+
iconFileName, existingEtag := appicon.ParseIconField(oldIcon)
225225

226226
reqHeaders := make(map[string]string)
227-
if existingEtag != "" {
227+
if existingEtag != "" && iconFileName != "" && appicon.IconFileExists(iconFileName) {
228228
reqHeaders["If-None-Match"] = existingEtag
229229
}
230230

0 commit comments

Comments
 (0)