@@ -14,7 +14,6 @@ import (
1414	"net/http" 
1515	"net/url" 
1616	"strconv" 
17- 	"strings" 
1817	"time" 
1918
2019	actions_model "code.gitea.io/gitea/models/actions" 
@@ -31,6 +30,7 @@ import (
3130	"code.gitea.io/gitea/modules/timeutil" 
3231	"code.gitea.io/gitea/modules/util" 
3332	"code.gitea.io/gitea/modules/web" 
33+ 	"code.gitea.io/gitea/routers/common" 
3434	actions_service "code.gitea.io/gitea/services/actions" 
3535	context_module "code.gitea.io/gitea/services/context" 
3636	notify_service "code.gitea.io/gitea/services/notify" 
@@ -469,49 +469,19 @@ func Logs(ctx *context_module.Context) {
469469	runIndex  :=  getRunIndex (ctx )
470470	jobIndex  :=  ctx .PathParamInt64 ("job" )
471471
472- 	job , _  :=  getRunJobs (ctx , runIndex , jobIndex )
473- 	if  ctx .Written () {
474- 		return 
475- 	}
476- 	if  job .TaskID  ==  0  {
477- 		ctx .HTTPError (http .StatusNotFound , "job is not started" )
478- 		return 
479- 	}
480- 
481- 	err  :=  job .LoadRun (ctx )
482- 	if  err  !=  nil  {
483- 		ctx .HTTPError (http .StatusInternalServerError , err .Error ())
484- 		return 
485- 	}
486- 
487- 	task , err  :=  actions_model .GetTaskByID (ctx , job .TaskID )
488- 	if  err  !=  nil  {
489- 		ctx .HTTPError (http .StatusInternalServerError , err .Error ())
490- 		return 
491- 	}
492- 	if  task .LogExpired  {
493- 		ctx .HTTPError (http .StatusNotFound , "logs have been cleaned up" )
494- 		return 
495- 	}
496- 
497- 	reader , err  :=  actions .OpenLogs (ctx , task .LogInStorage , task .LogFilename )
472+ 	run , err  :=  actions_model .GetRunByIndex (ctx , ctx .Repo .Repository .ID , runIndex )
498473	if  err  !=  nil  {
499- 		ctx .HTTPError (http .StatusInternalServerError , err .Error ())
474+ 		ctx .NotFoundOrServerError ("GetRunByIndex" , func (err  error ) bool  {
475+ 			return  errors .Is (err , util .ErrNotExist )
476+ 		}, err )
500477		return 
501478	}
502- 	defer  reader .Close ()
503479
504- 	workflowName  :=  job .Run .WorkflowID 
505- 	if  p  :=  strings .Index (workflowName , "." ); p  >  0  {
506- 		workflowName  =  workflowName [0 :p ]
480+ 	if  err  =  common .DownloadActionsRunJobLogsWithIndex (ctx .Base , ctx .Repo .Repository , run .ID , jobIndex ); err  !=  nil  {
481+ 		ctx .NotFoundOrServerError ("DownloadActionsRunJobLogsWithIndex" , func (err  error ) bool  {
482+ 			return  errors .Is (err , util .ErrNotExist )
483+ 		}, err )
507484	}
508- 	ctx .ServeContent (reader , & context_module.ServeHeaderOptions {
509- 		Filename :           fmt .Sprintf ("%v-%v-%v.log" , workflowName , job .Name , task .ID ),
510- 		ContentLength :      & task .LogSize ,
511- 		ContentType :        "text/plain" ,
512- 		ContentTypeCharset : "utf-8" ,
513- 		Disposition :        "attachment" ,
514- 	})
515485}
516486
517487func  Cancel (ctx  * context_module.Context ) {
0 commit comments