diff options
author | Jason Song <i@wolfogre.com> | 2023-05-12 21:30:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 13:30:28 +0000 |
commit | a7773d28d22988f67ca391ded3b35093bfa49d76 (patch) | |
tree | 36c07a872efee5495a3f49a248d373472bab50c0 | |
parent | b5c26fa825e08122843ad6d27191d399a9af1c37 (diff) | |
download | gitea-a7773d28d22988f67ca391ded3b35093bfa49d76.tar.gz gitea-a7773d28d22988f67ca391ded3b35093bfa49d76.zip |
Support migrating storage for actions log via command line (#24679)
Close #24677
---------
Co-authored-by: Giteabot <teabot@gitea.io>
-rw-r--r-- | cmd/migrate_storage.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index 9798913705..291e7695b5 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -8,6 +8,7 @@ import ( "fmt" "strings" + actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" "code.gitea.io/gitea/models/migrations" @@ -32,7 +33,7 @@ var CmdMigrateStorage = cli.Command{ cli.StringFlag{ Name: "type, t", Value: "", - Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages'", + Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log'", }, cli.StringFlag{ Name: "storage, s", @@ -134,6 +135,22 @@ func migratePackages(ctx context.Context, dstStorage storage.ObjectStorage) erro }) } +func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) error { + return db.Iterate(ctx, nil, func(ctx context.Context, task *actions_model.ActionTask) error { + if task.LogExpired { + // the log has been cleared + return nil + } + if !task.LogInStorage { + // running tasks store logs in DBFS + return nil + } + p := task.LogFilename + _, err := storage.Copy(dstStorage, p, storage.Actions, p) + return err + }) +} + func runMigrateStorage(ctx *cli.Context) error { stdCtx, cancel := installSignals() defer cancel() @@ -201,6 +218,7 @@ func runMigrateStorage(ctx *cli.Context) error { "repo-avatars": migrateRepoAvatars, "repo-archivers": migrateRepoArchivers, "packages": migratePackages, + "actions-log": migrateActionsLog, } tp := strings.ToLower(ctx.String("type")) |