diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-10-14 21:07:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-14 21:07:51 +0800 |
commit | 80a6b0f5bce15a641fc75f5f1ef6e42ef54424bc (patch) | |
tree | 504c7ccdc9cb42e0e282abdd8dbb75c4b24e9f5b /cmd | |
parent | 93f7525061bc9e6f5be734aba0de31b64c63d7a8 (diff) | |
download | gitea-80a6b0f5bce15a641fc75f5f1ef6e42ef54424bc.tar.gz gitea-80a6b0f5bce15a641fc75f5f1ef6e42ef54424bc.zip |
Avatars and Repo avatars support storing in minio (#12516)
* Avatar support minio
* Support repo avatar minio storage
* Add missing migration
* Fix bug
* Fix test
* Add test for minio store type on avatars and repo avatars; Add documents
* Fix bug
* Fix bug
* Add back missed avatar link method
* refactor codes
* Simplify the codes
* Code improvements
* Fix lint
* Fix test mysql
* Fix test mysql
* Fix test mysql
* Fix settings
* Fix test
* fix test
* Fix bug
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/migrate_storage.go | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index 5f19556d87..871baed92d 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -91,6 +91,20 @@ func migrateLFS(dstStorage storage.ObjectStorage) error { }) } +func migrateAvatars(dstStorage storage.ObjectStorage) error { + return models.IterateUser(func(user *models.User) error { + _, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath()) + return err + }) +} + +func migrateRepoAvatars(dstStorage storage.ObjectStorage) error { + return models.IterateRepository(func(repo *models.Repository) error { + _, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath()) + return err + }) +} + func runMigrateStorage(ctx *cli.Context) error { if err := initDB(); err != nil { return err @@ -142,9 +156,8 @@ func runMigrateStorage(ctx *cli.Context) error { UseSSL: ctx.Bool("minio-use-ssl"), }) default: - return fmt.Errorf("Unsupported attachments storage type: %s", ctx.String("storage")) + return fmt.Errorf("Unsupported storage type: %s", ctx.String("storage")) } - if err != nil { return err } @@ -159,6 +172,14 @@ func runMigrateStorage(ctx *cli.Context) error { if err := migrateLFS(dstStorage); err != nil { return err } + case "avatars": + if err := migrateAvatars(dstStorage); err != nil { + return err + } + case "repo-avatars": + if err := migrateRepoAvatars(dstStorage); err != nil { + return err + } default: return fmt.Errorf("Unsupported storage: %s", ctx.String("type")) } |