]> source.dussan.org Git - gitea.git/commitdiff
Always update expiration time when creating an artifact (#32281) (#32285)
authorZettat123 <zettat123@gmail.com>
Fri, 18 Oct 2024 02:36:23 +0000 (10:36 +0800)
committerGitHub <noreply@github.com>
Fri, 18 Oct 2024 02:36:23 +0000 (10:36 +0800)
Backport #32281

Fix #32256

models/actions/artifact.go

index 3d0a288e6287e9512d2a61e418119e00640d075c..0bc66ba24e8467e9a3182eb99e9d088af1994dc8 100644 (file)
@@ -69,7 +69,7 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa
                        OwnerID:      t.OwnerID,
                        CommitSHA:    t.CommitSHA,
                        Status:       int64(ArtifactStatusUploadPending),
-                       ExpiredUnix:  timeutil.TimeStamp(time.Now().Unix() + 3600*24*expiredDays),
+                       ExpiredUnix:  timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays),
                }
                if _, err := db.GetEngine(ctx).Insert(artifact); err != nil {
                        return nil, err
@@ -78,6 +78,13 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa
        } else if err != nil {
                return nil, err
        }
+
+       if _, err := db.GetEngine(ctx).ID(artifact.ID).Cols("expired_unix").Update(&ActionArtifact{
+               ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays),
+       }); err != nil {
+               return nil, err
+       }
+
        return artifact, nil
 }