mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Add HEAD support for rpm repo files (#28309)
				
					
				
			Fixes https://codeberg.org/forgejo/forgejo/issues/1810 zypper uses HEAD requests to check file existence. https://github.com/openSUSE/libzypp/blob/HEAD/zypp/RepoManager.cc#L2549 https://github.com/openSUSE/libzypp/blob/HEAD/zypp-curl/ng/network/private/downloaderstates/basicdownloader_p.cc#L116 @ExplodingDragon fyi
This commit is contained in:
		| @@ -57,6 +57,30 @@ func GetRepositoryKey(ctx *context.Context) { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func CheckRepositoryFileExistence(ctx *context.Context) { | ||||
| 	pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID) | ||||
| 	if err != nil { | ||||
| 		apiError(ctx, http.StatusInternalServerError, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey) | ||||
| 	if err != nil { | ||||
| 		if errors.Is(err, util.ErrNotExist) { | ||||
| 			ctx.Status(http.StatusNotFound) | ||||
| 		} else { | ||||
| 			apiError(ctx, http.StatusInternalServerError, err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	ctx.SetServeHeaders(&context.ServeHeaderOptions{ | ||||
| 		Filename:     pf.Name, | ||||
| 		LastModified: pf.CreatedUnix.AsLocalTime(), | ||||
| 	}) | ||||
| 	ctx.Status(http.StatusOK) | ||||
| } | ||||
|  | ||||
| // Gets a pre-generated repository metadata file | ||||
| func GetRepositoryFile(ctx *context.Context) { | ||||
| 	pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user