fix sqlite lock (#5184)
* fix sqlite lock * fix bug Co-Authored-By: lunny <xiaolunwen@gmail.com> * fix bug Co-Authored-By: lunny <xiaolunwen@gmail.com>release/v1.15
parent
99c09dfbfa
commit
2b7c366f64
|
@ -655,9 +655,9 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, repo *Repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for open dependencies
|
// Check for open dependencies
|
||||||
if isClosed && issue.Repo.IsDependenciesEnabled() {
|
if isClosed && issue.Repo.isDependenciesEnabled(e) {
|
||||||
// only check if dependencies are enabled and we're about to close an issue, otherwise reopening an issue would fail when there are unsatisfied dependencies
|
// only check if dependencies are enabled and we're about to close an issue, otherwise reopening an issue would fail when there are unsatisfied dependencies
|
||||||
noDeps, err := IssueNoDependenciesLeft(issue)
|
noDeps, err := issueNoDependenciesLeft(e, issue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -721,6 +721,7 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
|
||||||
if err = sess.Commit(); err != nil {
|
if err = sess.Commit(); err != nil {
|
||||||
return fmt.Errorf("Commit: %v", err)
|
return fmt.Errorf("Commit: %v", err)
|
||||||
}
|
}
|
||||||
|
sess.Close()
|
||||||
|
|
||||||
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo)
|
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo)
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
|
|
|
@ -113,8 +113,11 @@ func issueDepExists(e Engine, issueID int64, depID int64) (bool, error) {
|
||||||
|
|
||||||
// IssueNoDependenciesLeft checks if issue can be closed
|
// IssueNoDependenciesLeft checks if issue can be closed
|
||||||
func IssueNoDependenciesLeft(issue *Issue) (bool, error) {
|
func IssueNoDependenciesLeft(issue *Issue) (bool, error) {
|
||||||
|
return issueNoDependenciesLeft(x, issue)
|
||||||
|
}
|
||||||
|
|
||||||
exists, err := x.
|
func issueNoDependenciesLeft(e Engine, issue *Issue) (bool, error) {
|
||||||
|
exists, err := e.
|
||||||
Table("issue_dependency").
|
Table("issue_dependency").
|
||||||
Select("issue.*").
|
Select("issue.*").
|
||||||
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
|
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
|
||||||
|
@ -127,9 +130,13 @@ func IssueNoDependenciesLeft(issue *Issue) (bool, error) {
|
||||||
|
|
||||||
// IsDependenciesEnabled returns if dependecies are enabled and returns the default setting if not set.
|
// IsDependenciesEnabled returns if dependecies are enabled and returns the default setting if not set.
|
||||||
func (repo *Repository) IsDependenciesEnabled() bool {
|
func (repo *Repository) IsDependenciesEnabled() bool {
|
||||||
|
return repo.isDependenciesEnabled(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) isDependenciesEnabled(e Engine) bool {
|
||||||
var u *RepoUnit
|
var u *RepoUnit
|
||||||
var err error
|
var err error
|
||||||
if u, err = repo.GetUnit(UnitTypeIssues); err != nil {
|
if u, err = repo.getUnit(e, UnitTypeIssues); err != nil {
|
||||||
log.Trace("%s", err)
|
log.Trace("%s", err)
|
||||||
return setting.Service.DefaultEnableDependencies
|
return setting.Service.DefaultEnableDependencies
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,7 +448,11 @@ func (repo *Repository) MustGetUnit(tp UnitType) *RepoUnit {
|
||||||
|
|
||||||
// GetUnit returns a RepoUnit object
|
// GetUnit returns a RepoUnit object
|
||||||
func (repo *Repository) GetUnit(tp UnitType) (*RepoUnit, error) {
|
func (repo *Repository) GetUnit(tp UnitType) (*RepoUnit, error) {
|
||||||
if err := repo.getUnits(x); err != nil {
|
return repo.getUnit(x, tp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) getUnit(e Engine, tp UnitType) (*RepoUnit, error) {
|
||||||
|
if err := repo.getUnits(e); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, unit := range repo.Units {
|
for _, unit := range repo.Units {
|
||||||
|
|
Loading…
Reference in New Issue