diff options
author | Giteabot <teabot@gitea.io> | 2023-12-16 22:06:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-16 22:06:37 +0800 |
commit | 8ee1ed877b0207d9d8733ac32270325c54659909 (patch) | |
tree | 42c233cec25ffce95349f251e143e98ca5dc50bb /modules | |
parent | 2c2e00899d55f9b391ef91470177ac0aa19fdd38 (diff) | |
download | gitea-8ee1ed877b0207d9d8733ac32270325c54659909.tar.gz gitea-8ee1ed877b0207d9d8733ac32270325c54659909.zip |
Initalize stroage for orphaned repository doctor (#28487) (#28490)
Backport #28487 by @earl-warren
- When a repository is orphaned and has objects stored in any of the
storages such as repository avatar or attachments the delete function
would error, because the storage module wasn't initalized.
- Add code to initialize the storage module.
Refs: https://codeberg.org/forgejo/forgejo/pulls/1954
Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/doctor/repository.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/doctor/repository.go b/modules/doctor/repository.go index 46c64f9f4b..7de018936a 100644 --- a/modules/doctor/repository.go +++ b/modules/doctor/repository.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/storage" repo_service "code.gitea.io/gitea/services/repository" "xorm.io/builder" @@ -31,6 +32,10 @@ func countOrphanedRepos(ctx context.Context) (int64, error) { // deleteOrphanedRepos delete repository where user of owner_id do not exist func deleteOrphanedRepos(ctx context.Context) (int64, error) { + if err := storage.Init(); err != nil { + return 0, err + } + batchSize := db.MaxBatchInsertSize("repository") e := db.GetEngine(ctx) var deleted int64 |