1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-26 18:44:27 +00:00

Fix missing migrate actions artifacts (#30874) (#30886)

Backport #30874 by @lunny

The actions artifacts should be able to be migrate to the new storage
place.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Giteabot 2024-05-07 21:59:00 +08:00 committed by GitHub
parent d5563be0ee
commit 216c8eada3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,7 +34,7 @@ var CmdMigrateStorage = &cli.Command{
Name: "type", Name: "type",
Aliases: []string{"t"}, Aliases: []string{"t"},
Value: "", Value: "",
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log'", Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log', 'actions-artifacts",
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "storage", Name: "storage",
@ -160,6 +160,13 @@ func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) er
}) })
} }
func migrateActionsArtifacts(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, artifact *actions_model.ActionArtifact) error {
_, err := storage.Copy(dstStorage, artifact.ArtifactPath, storage.ActionsArtifacts, artifact.ArtifactPath)
return err
})
}
func runMigrateStorage(ctx *cli.Context) error { func runMigrateStorage(ctx *cli.Context) error {
stdCtx, cancel := installSignals() stdCtx, cancel := installSignals()
defer cancel() defer cancel()
@ -230,6 +237,7 @@ func runMigrateStorage(ctx *cli.Context) error {
"repo-archivers": migrateRepoArchivers, "repo-archivers": migrateRepoArchivers,
"packages": migratePackages, "packages": migratePackages,
"actions-log": migrateActionsLog, "actions-log": migrateActionsLog,
"actions-artifacts": migrateActionsArtifacts,
} }
tp := strings.ToLower(ctx.String("type")) tp := strings.ToLower(ctx.String("type"))