"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "models/repo.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

repo.go  (gitea-1.13.1):repo.go  (gitea-1.13.2)
skipping to change at line 1603 skipping to change at line 1603
if len(units) > 0 { if len(units) > 0 {
if _, err = sess.Insert(units); err != nil { if _, err = sess.Insert(units); err != nil {
return err return err
} }
} }
return sess.Commit() return sess.Commit()
} }
// DeleteRepository deletes a repository for a user or organization. // DeleteRepository deletes a repository for a user or organization.
// make sure if you call this func to close open sessions (sqlite will otherwise get a deadlock)
func DeleteRepository(doer *User, uid, repoID int64) error { func DeleteRepository(doer *User, uid, repoID int64) error {
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}
// In case is a organization. // In case is a organization.
org, err := GetUserByID(uid) org, err := getUserByID(sess, uid)
if err != nil { if err != nil {
return err return err
} }
if org.IsOrganization() { if org.IsOrganization() {
if err = org.GetTeams(&SearchTeamOptions{}); err != nil { if err = org.getTeams(sess); err != nil {
return err return err
} }
} }
sess := x.NewSession() repo := &Repository{OwnerID: uid}
defer sess.Close() has, err := sess.ID(repoID).Get(repo)
if err = sess.Begin(); err != nil {
return err
}
repo := &Repository{ID: repoID, OwnerID: uid}
has, err := sess.Get(repo)
if err != nil { if err != nil {
return err return err
} else if !has { } else if !has {
return ErrRepoNotExist{repoID, uid, "", ""} return ErrRepoNotExist{repoID, uid, "", ""}
} }
// Delete Deploy Keys // Delete Deploy Keys
deployKeys, err := listDeployKeys(sess, repo.ID, ListOptions{}) deployKeys, err := listDeployKeys(sess, repo.ID, ListOptions{})
if err != nil { if err != nil {
return fmt.Errorf("listDeployKeys: %v", err) return fmt.Errorf("listDeployKeys: %v", err)
skipping to change at line 1771 skipping to change at line 1772
return err return err
} }
if repo.NumForks > 0 { if repo.NumForks > 0 {
if _, err = sess.Exec("UPDATE `repository` SET fork_id=0,is_fork= ? WHERE fork_id=?", false, repo.ID); err != nil { if _, err = sess.Exec("UPDATE `repository` SET fork_id=0,is_fork= ? WHERE fork_id=?", false, repo.ID); err != nil {
log.Error("reset 'fork_id' and 'is_fork': %v", err) log.Error("reset 'fork_id' and 'is_fork': %v", err)
} }
} }
if err = sess.Commit(); err != nil { if err = sess.Commit(); err != nil {
sess.Close() return err
if len(deployKeys) > 0 {
// We need to rewrite the public keys because the commit
failed
if err2 := RewriteAllPublicKeys(); err2 != nil {
return fmt.Errorf("Commit: %v SSH Keys: %v", err,
err2)
}
}
return fmt.Errorf("Commit: %v", err)
} }
sess.Close() sess.Close()
// We should always delete the files after the database transaction succe ed. If // We should always delete the files after the database transaction succe ed. If
// we delete the file but the database rollback, the repository will be b orken. // we delete the file but the database rollback, the repository will be b orken.
// Remove issue attachment files. // Remove issue attachment files.
for i := range attachmentPaths { for i := range attachmentPaths {
RemoveStorageWithNotice(storage.Attachments, "Delete issue attach ment", attachmentPaths[i]) RemoveStorageWithNotice(storage.Attachments, "Delete issue attach ment", attachmentPaths[i])
 End of changes. 6 change blocks. 
20 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)