aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-08-25 18:05:21 +0200
committerGitHub <noreply@github.com>2022-08-25 12:05:21 -0400
commitdc0253b0637bbf367ad330612900e780c6b2b0e6 (patch)
tree85a51c2e9b355bef889e6fdae2e71b49fd645fbb /routers
parent5e232e86de6bb26038e0ebaec60368d54a327446 (diff)
downloadgitea-dc0253b0637bbf367ad330612900e780c6b2b0e6.tar.gz
gitea-dc0253b0637bbf367ad330612900e780c6b2b0e6.zip
Replace `ServeStream` with `ServeContent` (#20903)
* Replace ServeStream with ServeContent. * Update modules/timeutil/timestamp.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/packages/composer/api.go2
-rw-r--r--routers/api/packages/composer/composer.go2
-rw-r--r--routers/api/packages/conan/conan.go8
-rw-r--r--routers/api/packages/generic/generic.go2
-rw-r--r--routers/api/packages/helm/helm.go2
-rw-r--r--routers/api/packages/maven/maven.go2
-rw-r--r--routers/api/packages/npm/npm.go2
-rw-r--r--routers/api/packages/nuget/api.go2
-rw-r--r--routers/api/packages/nuget/nuget.go6
-rw-r--r--routers/api/packages/pub/pub.go4
-rw-r--r--routers/api/packages/pypi/pypi.go2
-rw-r--r--routers/api/packages/rubygems/rubygems.go2
-rw-r--r--routers/web/repo/repo.go3
-rw-r--r--routers/web/user/package.go2
14 files changed, 21 insertions, 20 deletions
diff --git a/routers/api/packages/composer/api.go b/routers/api/packages/composer/api.go
index 45bb7eae1c..ed52d16513 100644
--- a/routers/api/packages/composer/api.go
+++ b/routers/api/packages/composer/api.go
@@ -99,7 +99,7 @@ func createPackageMetadataResponse(registryURL string, pds []*packages_model.Pac
Name: pd.Package.Name,
Version: pd.Version.Version,
Type: packageType,
- Created: time.Unix(int64(pd.Version.CreatedUnix), 0),
+ Created: pd.Version.CreatedUnix.AsLocalTime(),
Metadata: pd.Metadata.(*composer_module.Metadata),
Dist: Dist{
Type: "zip",
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index 81cef39f1c..86ef7cbd9a 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -184,7 +184,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackage creates a new package
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go
index 04b0bb6cdd..90924c7c4b 100644
--- a/routers/api/packages/conan/conan.go
+++ b/routers/api/packages/conan/conan.go
@@ -475,7 +475,7 @@ func downloadFile(ctx *context.Context, fileFilter stringSet, fileKey string) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// DeleteRecipeV1 deletes the requested recipe(s)
@@ -723,7 +723,7 @@ func listRevisions(ctx *context.Context, revisions []*conan_model.PropertyValue)
revs := make([]*revisionInfo, 0, len(revisions))
for _, rev := range revisions {
- revs = append(revs, &revisionInfo{Revision: rev.Value, Time: time.Unix(int64(rev.CreatedUnix), 0)})
+ revs = append(revs, &revisionInfo{Revision: rev.Value, Time: rev.CreatedUnix.AsLocalTime()})
}
jsonResponse(ctx, http.StatusOK, &RevisionList{revs})
@@ -743,7 +743,7 @@ func LatestRecipeRevision(ctx *context.Context) {
return
}
- jsonResponse(ctx, http.StatusOK, &revisionInfo{Revision: revision.Value, Time: time.Unix(int64(revision.CreatedUnix), 0)})
+ jsonResponse(ctx, http.StatusOK, &revisionInfo{Revision: revision.Value, Time: revision.CreatedUnix.AsLocalTime()})
}
// LatestPackageRevision gets the latest package revision
@@ -760,7 +760,7 @@ func LatestPackageRevision(ctx *context.Context) {
return
}
- jsonResponse(ctx, http.StatusOK, &revisionInfo{Revision: revision.Value, Time: time.Unix(int64(revision.CreatedUnix), 0)})
+ jsonResponse(ctx, http.StatusOK, &revisionInfo{Revision: revision.Value, Time: revision.CreatedUnix.AsLocalTime()})
}
// ListRecipeRevisionFiles gets a list of all recipe revision files
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go
index 79e5afb03c..81891bec26 100644
--- a/routers/api/packages/generic/generic.go
+++ b/routers/api/packages/generic/generic.go
@@ -53,7 +53,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackage uploads the specific generic package.
diff --git a/routers/api/packages/helm/helm.go b/routers/api/packages/helm/helm.go
index f59cfc7c7b..9c85e0874f 100644
--- a/routers/api/packages/helm/helm.go
+++ b/routers/api/packages/helm/helm.go
@@ -138,7 +138,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackage creates a new package
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index 072a15f95c..bf00c199f5 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -177,7 +177,7 @@ func servePackageFile(ctx *context.Context, params parameters) {
}
}
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackageFile adds a file to the package. If the package does not exist, it gets created.
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index d5ba70f964..66b999d47e 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -103,7 +103,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackage creates a new package
diff --git a/routers/api/packages/nuget/api.go b/routers/api/packages/nuget/api.go
index b449cfc5bb..964e05f926 100644
--- a/routers/api/packages/nuget/api.go
+++ b/routers/api/packages/nuget/api.go
@@ -176,7 +176,7 @@ func createRegistrationLeafResponse(l *linkBuilder, pd *packages_model.PackageDe
return &RegistrationLeafResponse{
Type: []string{"Package", "http://schema.nuget.org/catalog#Permalink"},
Listed: true,
- Published: time.Unix(int64(pd.Version.CreatedUnix), 0),
+ Published: pd.Version.CreatedUnix.AsLocalTime(),
RegistrationLeafURL: l.GetRegistrationLeafURL(pd.Package.Name, pd.Version.Version),
PackageContentURL: l.GetPackageDownloadURL(pd.Package.Name, pd.Version.Version),
RegistrationIndexURL: l.GetRegistrationIndexURL(pd.Package.Name),
diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go
index 81ea28bcad..eadf7486a5 100644
--- a/routers/api/packages/nuget/nuget.go
+++ b/routers/api/packages/nuget/nuget.go
@@ -179,7 +179,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackage creates a new package with the metadata contained in the uploaded nupgk file
@@ -378,7 +378,7 @@ func DownloadSymbolFile(ctx *context.Context) {
return
}
- s, _, err := packages_service.GetPackageFileStream(ctx, pfs[0])
+ s, pf, err := packages_service.GetPackageFileStream(ctx, pfs[0])
if err != nil {
if err == packages_model.ErrPackageNotExist || err == packages_model.ErrPackageFileNotExist {
apiError(ctx, http.StatusNotFound, err)
@@ -389,7 +389,7 @@ func DownloadSymbolFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pfs[0].Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// DeletePackage hard deletes the package
diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go
index 470f446238..9af0ceeb0e 100644
--- a/routers/api/packages/pub/pub.go
+++ b/routers/api/packages/pub/pub.go
@@ -69,7 +69,7 @@ func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescr
return &versionMetadata{
Version: pd.Version.Version,
ArchiveURL: fmt.Sprintf("%s/files/%s.tar.gz", baseURL, url.PathEscape(pd.Version.Version)),
- Published: time.Unix(int64(pd.Version.CreatedUnix), 0),
+ Published: pd.Version.CreatedUnix.AsLocalTime(),
Pubspec: pd.Metadata.(*pub_module.Metadata).Pubspec,
}
}
@@ -271,5 +271,5 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go
index 9209c4edd5..3909074504 100644
--- a/routers/api/packages/pypi/pypi.go
+++ b/routers/api/packages/pypi/pypi.go
@@ -90,7 +90,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackageFile adds a file to the package. If the package does not exist, it gets created.
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index 4f066a8303..319c94b91f 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -188,7 +188,7 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}
// UploadPackageFile adds a file to the package. If the package does not exist, it gets created.
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index fe95d1e478..ae0351a219 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -468,7 +468,8 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
return
}
defer fr.Close()
- ctx.ServeStream(fr, downloadName)
+
+ ctx.ServeContent(downloadName, fr, archiver.CreatedUnix.AsLocalTime())
}
// InitiateDownload will enqueue an archival request, as needed. It may submit
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index 59aaf07ff2..20d8e32d29 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -393,5 +393,5 @@ func DownloadPackageFile(ctx *context.Context) {
}
defer s.Close()
- ctx.ServeStream(s, pf.Name)
+ ctx.ServeContent(pf.Name, s, pf.CreatedUnix.AsLocalTime())
}