commands

package
v4.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllBranchCache = func() error {
	var (
		enabledGitProjects []*models.GitProject
		wg                 = &sync.WaitGroup{}
	)

	app.DB().Where("`enabled` = ?", true).Find(&enabledGitProjects)
	goroutineNum := len(enabledGitProjects)

	if len(enabledGitProjects) > 10 {
		goroutineNum = 8
	}

	ch := make(chan *models.GitProject, goroutineNum)
	gitServer := plugins.GetGitServer()
	if server, ok := gitServer.(plugins.GitCacheServer); ok {
		for i := 0; i < goroutineNum; i++ {
			wg.Add(1)
			go func() {
				defer wg.Done()
				defer recovery.HandlePanic("[CRON]: all_branch_cache")
				for gitProject := range ch {
					err := server.ReCacheAllBranches(fmt.Sprintf("%d", gitProject.GitProjectId))
					mlog.Debugf("[CRON]: fetch AllBranches: '%s' '%d', err: '%v'", gitProject.Name, gitProject.GitProjectId, err)
				}
			}()
		}
		for i := range enabledGitProjects {
			ch <- enabledGitProjects[i]
		}
		close(ch)
		wg.Wait()
	}

	return nil
}
View Source
var AllGitProjectCache = func() error {
	var gitServer plugins.GitServer = plugins.GetGitServer()
	if cache, ok := gitServer.(plugins.GitCacheServer); ok {
		return cache.ReCacheAllProjects()
	}
	return nil
}

Functions

func CleanUploadFiles

func CleanUploadFiles() error

CleanUploadFiles

1. 删除在数据库中存在,但是磁盘里面没有的文件 2. 删除本地磁盘有的,但是不存在于数据库中的文件

dangerous !

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL