@@ -1013,9 +1013,10 @@ func (h *RepoHandler) SDKListFiles(ctx *gin.Context) {
10131013 if mappedBranch != "" {
10141014 ref = mappedBranch
10151015 }
1016+ repoType := common .RepoTypeFromContext (ctx )
10161017 expand := ctx .Query ("expand" )
10171018 if expand == "xetEnabled" {
1018- resp , err := h .c .IsXnetEnabled (ctx .Request .Context (), types . ModelRepo , namespace , name , currentUser )
1019+ resp , err := h .c .IsXnetEnabled (ctx .Request .Context (), repoType , namespace , name , currentUser )
10191020 if err != nil {
10201021 slog .ErrorContext (ctx .Request .Context (), "failed to check if xnetEnabled" , slog .Any ("error" , err ))
10211022 httpbase .ServerError (ctx , err )
@@ -1025,15 +1026,15 @@ func (h *RepoHandler) SDKListFiles(ctx *gin.Context) {
10251026 return
10261027 }
10271028
1028- files , err := h .c .SDKListFiles (ctx .Request .Context (), common . RepoTypeFromContext ( ctx ) , namespace , name , ref , currentUser )
1029+ files , err := h .c .SDKListFiles (ctx .Request .Context (), repoType , namespace , name , ref , currentUser )
10291030 if err != nil {
10301031 if errors .Is (err , errorx .ErrUnauthorized ) {
1031- slog .ErrorContext (ctx .Request .Context (), "permission denied when accessing repo" , slog .String ("repo_type" , string (common . RepoTypeFromContext ( ctx ) )), slog .Any ("path" , fmt .Sprintf ("%s/%s" , namespace , name )))
1032+ slog .ErrorContext (ctx .Request .Context (), "permission denied when accessing repo" , slog .String ("repo_type" , string (repoType )), slog .Any ("path" , fmt .Sprintf ("%s/%s" , namespace , name )))
10321033 httpbase .UnauthorizedError (ctx , err )
10331034 return
10341035 }
10351036 if errors .Is (err , errorx .ErrNotFound ) {
1036- slog .ErrorContext (ctx .Request .Context (), "repo not found" , slog .String ("repo_type" , string (common . RepoTypeFromContext ( ctx ) )), slog .Any ("path" , fmt .Sprintf ("%s/%s" , namespace , name )))
1037+ slog .ErrorContext (ctx .Request .Context (), "repo not found" , slog .String ("repo_type" , string (repoType )), slog .Any ("path" , fmt .Sprintf ("%s/%s" , namespace , name )))
10371038 httpbase .NotFoundError (ctx , err )
10381039 return
10391040 }
@@ -1120,16 +1121,20 @@ func (h *RepoHandler) HeadSDKDownload(ctx *gin.Context) {
11201121 slog .Debug ("Head download repo file succeed" , slog .String ("repo_type" , string (req .RepoType )), slog .String ("name" , name ), slog .String ("path" , req .Path ), slog .String ("ref" , req .Ref ), slog .Int64 ("contentLength" , file .Size ))
11211122 if file .Lfs && file .XnetEnabled {
11221123 ctx .Header ("X-Xet-Hash" , file .LfsSHA256 )
1123- ctx .Header ("X-Xet-Refresh-Route" , h .xetRefreshRoute (namespace , name , branch ))
1124+ ctx .Header ("X-Xet-Refresh-Route" , h .xetRefreshRoute (req . RepoType , namespace , name , branch ))
11241125 }
11251126 ctx .Header ("Content-Length" , strconv .Itoa (int (file .Size )))
11261127 ctx .Header ("X-Repo-Commit" , repoCommit )
11271128 ctx .Header ("ETag" , file .SHA )
11281129 ctx .Status (http .StatusOK )
11291130}
11301131
1131- func (h * RepoHandler ) xetRefreshRoute (namespace , name , ref string ) string {
1132- return fmt .Sprintf ("%s/hf/%s/%s/xet-write-token/%s" , h .config .Model .DownloadEndpoint , namespace , name , ref )
1132+ func (h * RepoHandler ) xetRefreshRoute (repoType types.RepositoryType , namespace , name , ref string ) string {
1133+ if repoType == types .ModelRepo {
1134+ return fmt .Sprintf ("%s/hf/%s/%s/xet-write-token/%s" , h .config .Model .DownloadEndpoint , namespace , name , ref )
1135+ }
1136+ return fmt .Sprintf ("%s/hf/%ss/%s/%s/xet-write-token/%s" , h .config .Model .DownloadEndpoint , repoType , namespace , name , ref )
1137+
11331138}
11341139
11351140func (h * RepoHandler ) handleDownload (ctx * gin.Context , isResolve bool ) {
0 commit comments