Skip to content

Commit a7773d2

Browse files
wolfogreGiteaBot
andauthored
Support migrating storage for actions log via command line (#24679)
Close #24677 --------- Co-authored-by: Giteabot <[email protected]>
1 parent b5c26fa commit a7773d2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cmd/migrate_storage.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"strings"
1010

11+
actions_model "code.gitea.io/gitea/models/actions"
1112
"code.gitea.io/gitea/models/db"
1213
git_model "code.gitea.io/gitea/models/git"
1314
"code.gitea.io/gitea/models/migrations"
@@ -32,7 +33,7 @@ var CmdMigrateStorage = cli.Command{
3233
cli.StringFlag{
3334
Name: "type, t",
3435
Value: "",
35-
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages'",
36+
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log'",
3637
},
3738
cli.StringFlag{
3839
Name: "storage, s",
@@ -134,6 +135,22 @@ func migratePackages(ctx context.Context, dstStorage storage.ObjectStorage) erro
134135
})
135136
}
136137

138+
func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) error {
139+
return db.Iterate(ctx, nil, func(ctx context.Context, task *actions_model.ActionTask) error {
140+
if task.LogExpired {
141+
// the log has been cleared
142+
return nil
143+
}
144+
if !task.LogInStorage {
145+
// running tasks store logs in DBFS
146+
return nil
147+
}
148+
p := task.LogFilename
149+
_, err := storage.Copy(dstStorage, p, storage.Actions, p)
150+
return err
151+
})
152+
}
153+
137154
func runMigrateStorage(ctx *cli.Context) error {
138155
stdCtx, cancel := installSignals()
139156
defer cancel()
@@ -201,6 +218,7 @@ func runMigrateStorage(ctx *cli.Context) error {
201218
"repo-avatars": migrateRepoAvatars,
202219
"repo-archivers": migrateRepoArchivers,
203220
"packages": migratePackages,
221+
"actions-log": migrateActionsLog,
204222
}
205223

206224
tp := strings.ToLower(ctx.String("type"))

0 commit comments

Comments
 (0)