mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-10-22 07:22:33 +00:00
Stabilize feature expiration.
This commit is contained in:
+2
-6
@@ -45,12 +45,12 @@ func configureFeatures(ctx context.Context) (err error) {
|
||||
for _, feature := range config.Features {
|
||||
switch feature {
|
||||
// Work-in-progress features:
|
||||
case "preview", "expiration":
|
||||
case "preview":
|
||||
// Permanently unstable features:
|
||||
case "codeberg-pages-compat", "relaxed-idna":
|
||||
// Stabilized features:
|
||||
case "archive-site", "audit", "compress", "patch", "serve-h2c", "existence-cache",
|
||||
"absolute-headers":
|
||||
"absolute-headers", "expiration":
|
||||
logc.Printf(ctx, "feature %s has been stabilized", feature)
|
||||
// Removed or renamed features:
|
||||
case "h2c", "sentry-telemetry-buffer", "site-existence-cache", "domain-existence-cache":
|
||||
@@ -754,10 +754,6 @@ func Main(versionInfo string) {
|
||||
logc.Printf(ctx, "audit: expired %d records\n", count)
|
||||
|
||||
case *expireSites:
|
||||
if !config.Feature("expiration") {
|
||||
logc.Fatalf(ctx, "expire: feature disabled")
|
||||
}
|
||||
|
||||
countExpired, countTransient := 0, 0
|
||||
for item, err := range backend.GetAllManifests(ctx) {
|
||||
metadata, manifest := item.Splat()
|
||||
|
||||
+13
-15
@@ -518,22 +518,20 @@ func getUpdateOptions(
|
||||
) (opts UpdateOptions, ok bool) {
|
||||
var err error
|
||||
|
||||
if config.Feature("expiration") {
|
||||
if expires := r.Header.Get("Expires"); expires != "" {
|
||||
opts.expiresAt, err = time.Parse(http.TimeFormat, expires)
|
||||
if err != nil {
|
||||
http.Error(w, "malformed Expires: header", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !config.Limits.AllowExpiration {
|
||||
http.Error(w, "expiration forbidden by policy", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if expires := r.Header.Get("Expires"); expires != "" {
|
||||
opts.expiresAt, err = time.Parse(http.TimeFormat, expires)
|
||||
if err != nil {
|
||||
http.Error(w, "malformed Expires: header", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if !auth.expiresNoLater.IsZero() {
|
||||
if opts.expiresAt.IsZero() || opts.expiresAt.After(auth.expiresNoLater) {
|
||||
opts.expiresAt = auth.expiresNoLater
|
||||
}
|
||||
if !config.Limits.AllowExpiration {
|
||||
http.Error(w, "expiration forbidden by policy", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
if !auth.expiresNoLater.IsZero() {
|
||||
if opts.expiresAt.IsZero() || opts.expiresAt.After(auth.expiresNoLater) {
|
||||
opts.expiresAt = auth.expiresNoLater
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user