|
@@ -11,6 +11,7 @@ import ( |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"html/template" |
|
|
"html/template" |
|
|
|
|
|
"xorm.io/xorm" |
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/blockchain" |
|
|
"code.gitea.io/gitea/modules/blockchain" |
|
|
|
|
|
|
|
@@ -1632,6 +1633,9 @@ func DeleteRepository(doer *User, uid, repoID int64) error { |
|
|
releaseAttachments = append(releaseAttachments, attachments[i].RelativePath()) |
|
|
releaseAttachments = append(releaseAttachments, attachments[i].RelativePath()) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete dataset attachment record and remove related files |
|
|
|
|
|
deleteDatasetAttachmentByRepoId(sess, repoID) |
|
|
|
|
|
|
|
|
if err = deleteBeans(sess, |
|
|
if err = deleteBeans(sess, |
|
|
&Access{RepoID: repo.ID}, |
|
|
&Access{RepoID: repo.ID}, |
|
|
&Action{RepoID: repo.ID}, |
|
|
&Action{RepoID: repo.ID}, |
|
@@ -1817,6 +1821,20 @@ func DeleteRepository(doer *User, uid, repoID int64) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func deleteDatasetAttachmentByRepoId(sess *xorm.Session, repoId int64) error { |
|
|
|
|
|
attachments := make([]*Attachment, 0) |
|
|
|
|
|
if err := sess.Join("INNER", "dataset", "dataset.id = attachment.dataset_id"). |
|
|
|
|
|
Where("dataset.repo_id = ?", repoId). |
|
|
|
|
|
Find(&attachments); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
if len(attachments) == 0 { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
_, err := DeleteAttachments(attachments, true) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// GetRepositoryByOwnerAndName returns the repository by given ownername and reponame. |
|
|
// GetRepositoryByOwnerAndName returns the repository by given ownername and reponame. |
|
|
func GetRepositoryByOwnerAndName(ownerName, repoName string) (*Repository, error) { |
|
|
func GetRepositoryByOwnerAndName(ownerName, repoName string) (*Repository, error) { |
|
|
return getRepositoryByOwnerAndName(x, ownerName, repoName) |
|
|
return getRepositoryByOwnerAndName(x, ownerName, repoName) |
|
|