mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-30 05:07:06 +08:00
1d332342db
* Added package store settings. * Added models. * Added generic package registry. * Added tests. * Added NuGet package registry. * Moved service index to api file. * Added NPM package registry. * Added Maven package registry. * Added PyPI package registry. * Summary is deprecated. * Changed npm name. * Sanitize project url. * Allow only scoped packages. * Added user interface. * Changed method name. * Added missing migration file. * Set page info. * Added documentation. * Added documentation links. * Fixed wrong error message. * Lint template files. * Fixed merge errors. * Fixed unit test storage path. * Switch to json module. * Added suggestions. * Added package webhook. * Add package api. * Fixed swagger file. * Fixed enum and comments. * Fixed NuGet pagination. * Print test names. * Added api tests. * Fixed access level. * Fix User unmarshal. * Added RubyGems package registry. * Fix lint. * Implemented io.Writer. * Added support for sha256/sha512 checksum files. * Improved maven-metadata.xml support. * Added support for symbol package uploads. * Added tests. * Added overview docs. * Added npm dependencies and keywords. * Added no-packages information. * Display file size. * Display asset count. * Fixed filter alignment. * Added package icons. * Formatted instructions. * Allow anonymous package downloads. * Fixed comments. * Fixed postgres test. * Moved file. * Moved models to models/packages. * Use correct error response format per client. * Use simpler search form. * Fixed IsProd. * Restructured data model. * Prevent empty filename. * Fix swagger. * Implemented user/org registry. * Implemented UI. * Use GetUserByIDCtx. * Use table for dependencies. * make svg * Added support for unscoped npm packages. * Add support for npm dist tags. * Added tests for npm tags. * Unlink packages if repository gets deleted. * Prevent user/org delete if a packages exist. * Use package unlink in repository service. * Added support for composer packages. * Restructured package docs. * Added missing tests. * Fixed generic content page. * Fixed docs. * Fixed swagger. * Added missing type. * Fixed ambiguous column. * Organize content store by sha256 hash. * Added admin package management. * Added support for sorting. * Add support for multiple identical versions/files. * Added missing repository unlink. * Added file properties. * make fmt * lint * Added Conan package registry. * Updated docs. * Unify package names. * Added swagger enum. * Use longer TEXT column type. * Removed version composite key. * Merged package and container registry. * Removed index. * Use dedicated package router. * Moved files to new location. * Updated docs. * Fixed JOIN order. * Fixed GROUP BY statement. * Fixed GROUP BY #2. * Added symbol server support. * Added more tests. * Set NOT NULL. * Added setting to disable package registries. * Moved auth into service. * refactor * Use ctx everywhere. * Added package cleanup task. * Changed packages path. * Added container registry. * Refactoring * Updated comparison. * Fix swagger. * Fixed table order. * Use token auth for npm routes. * Enabled ReverseProxy auth. * Added packages link for orgs. * Fixed anonymous org access. * Enable copy button for setup instructions. * Merge error * Added suggestions. * Fixed merge. * Handle "generic". * Added link for TODO. * Added suggestions. * Changed temporary buffer filename. * Added suggestions. * Apply suggestions from code review Co-authored-by: Thomas Boerger <thomas@webhippie.de> * Update docs/content/doc/packages/nuget.en-us.md Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Thomas Boerger <thomas@webhippie.de>
172 lines
4.8 KiB
Go
172 lines
4.8 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cron
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
user_model "code.gitea.io/gitea/models/user"
|
|
"code.gitea.io/gitea/models/webhook"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
"code.gitea.io/gitea/services/auth"
|
|
"code.gitea.io/gitea/services/migrations"
|
|
mirror_service "code.gitea.io/gitea/services/mirror"
|
|
packages_service "code.gitea.io/gitea/services/packages"
|
|
repo_service "code.gitea.io/gitea/services/repository"
|
|
archiver_service "code.gitea.io/gitea/services/repository/archiver"
|
|
)
|
|
|
|
func registerUpdateMirrorTask() {
|
|
type UpdateMirrorTaskConfig struct {
|
|
BaseConfig
|
|
PullLimit int
|
|
PushLimit int
|
|
}
|
|
|
|
RegisterTaskFatal("update_mirrors", &UpdateMirrorTaskConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: false,
|
|
Schedule: "@every 10m",
|
|
},
|
|
PullLimit: 50,
|
|
PushLimit: 50,
|
|
}, func(ctx context.Context, _ *user_model.User, cfg Config) error {
|
|
umtc := cfg.(*UpdateMirrorTaskConfig)
|
|
return mirror_service.Update(ctx, umtc.PullLimit, umtc.PushLimit)
|
|
})
|
|
}
|
|
|
|
func registerRepoHealthCheck() {
|
|
type RepoHealthCheckConfig struct {
|
|
BaseConfig
|
|
Timeout time.Duration
|
|
Args []string `delim:" "`
|
|
}
|
|
RegisterTaskFatal("repo_health_check", &RepoHealthCheckConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: false,
|
|
Schedule: "@midnight",
|
|
},
|
|
Timeout: 60 * time.Second,
|
|
Args: []string{},
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
rhcConfig := config.(*RepoHealthCheckConfig)
|
|
return repo_service.GitFsck(ctx, rhcConfig.Timeout, rhcConfig.Args)
|
|
})
|
|
}
|
|
|
|
func registerCheckRepoStats() {
|
|
RegisterTaskFatal("check_repo_stats", &BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: true,
|
|
Schedule: "@midnight",
|
|
}, func(ctx context.Context, _ *user_model.User, _ Config) error {
|
|
return models.CheckRepoStats(ctx)
|
|
})
|
|
}
|
|
|
|
func registerArchiveCleanup() {
|
|
RegisterTaskFatal("archive_cleanup", &OlderThanConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: true,
|
|
Schedule: "@midnight",
|
|
},
|
|
OlderThan: 24 * time.Hour,
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
acConfig := config.(*OlderThanConfig)
|
|
return archiver_service.DeleteOldRepositoryArchives(ctx, acConfig.OlderThan)
|
|
})
|
|
}
|
|
|
|
func registerSyncExternalUsers() {
|
|
RegisterTaskFatal("sync_external_users", &UpdateExistingConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: false,
|
|
Schedule: "@midnight",
|
|
},
|
|
UpdateExisting: true,
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
realConfig := config.(*UpdateExistingConfig)
|
|
return auth.SyncExternalUsers(ctx, realConfig.UpdateExisting)
|
|
})
|
|
}
|
|
|
|
func registerDeletedBranchesCleanup() {
|
|
RegisterTaskFatal("deleted_branches_cleanup", &OlderThanConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: true,
|
|
Schedule: "@midnight",
|
|
},
|
|
OlderThan: 24 * time.Hour,
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
realConfig := config.(*OlderThanConfig)
|
|
models.RemoveOldDeletedBranches(ctx, realConfig.OlderThan)
|
|
return nil
|
|
})
|
|
}
|
|
|
|
func registerUpdateMigrationPosterID() {
|
|
RegisterTaskFatal("update_migration_poster_id", &BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: true,
|
|
Schedule: "@midnight",
|
|
}, func(ctx context.Context, _ *user_model.User, _ Config) error {
|
|
return migrations.UpdateMigrationPosterID(ctx)
|
|
})
|
|
}
|
|
|
|
func registerCleanupHookTaskTable() {
|
|
RegisterTaskFatal("cleanup_hook_task_table", &CleanupHookTaskConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: false,
|
|
Schedule: "@midnight",
|
|
},
|
|
CleanupType: "OlderThan",
|
|
OlderThan: 168 * time.Hour,
|
|
NumberToKeep: 10,
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
realConfig := config.(*CleanupHookTaskConfig)
|
|
return webhook.CleanupHookTaskTable(ctx, webhook.ToHookTaskCleanupType(realConfig.CleanupType), realConfig.OlderThan, realConfig.NumberToKeep)
|
|
})
|
|
}
|
|
|
|
func registerCleanupPackages() {
|
|
RegisterTaskFatal("cleanup_packages", &OlderThanConfig{
|
|
BaseConfig: BaseConfig{
|
|
Enabled: true,
|
|
RunAtStart: true,
|
|
Schedule: "@midnight",
|
|
},
|
|
OlderThan: 24 * time.Hour,
|
|
}, func(ctx context.Context, _ *user_model.User, config Config) error {
|
|
realConfig := config.(*OlderThanConfig)
|
|
return packages_service.Cleanup(ctx, realConfig.OlderThan)
|
|
})
|
|
}
|
|
|
|
func initBasicTasks() {
|
|
registerUpdateMirrorTask()
|
|
registerRepoHealthCheck()
|
|
registerCheckRepoStats()
|
|
registerArchiveCleanup()
|
|
registerSyncExternalUsers()
|
|
registerDeletedBranchesCleanup()
|
|
if !setting.Repository.DisableMigrations {
|
|
registerUpdateMigrationPosterID()
|
|
}
|
|
registerCleanupHookTaskTable()
|
|
if setting.Packages.Enabled {
|
|
registerCleanupPackages()
|
|
}
|
|
}
|