api: repo copy handle package not found

and add tests for error proper handling.
This commit is contained in:
André Roth
2024-07-18 14:56:11 +02:00
parent 49184c9163
commit fe25414b45
3 changed files with 11 additions and 3 deletions

View File

@@ -524,6 +524,10 @@ func apiReposCopyPackage(c *gin.Context) {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("filter error: %s", err)
}
if toProcess.Len() == 0 {
return &task.ProcessReturnValue{Code: http.StatusUnprocessableEntity, Value: nil}, fmt.Errorf("no package found for filter: '%s'", fileName)
}
err = toProcess.ForEach(func(p *deb.Package) error {
err = dstList.Add(p)
if err != nil {