aboutsummaryrefslogtreecommitdiffstats
path: root/services/wiki/wiki.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-08 23:19:30 +0800
committerGitHub <noreply@github.com>2021-09-08 17:19:30 +0200
commitddc709ff7f94bd627ac05209a16ea5a5e24b7413 (patch)
tree1420d827e00769c1a8330c6b1a80e7cbbc343332 /services/wiki/wiki.go
parentf55cd033ed8dbee04e90faede5cca2dcf697e102 (diff)
downloadgitea-ddc709ff7f94bd627ac05209a16ea5a5e24b7413.tar.gz
gitea-ddc709ff7f94bd627ac05209a16ea5a5e24b7413.zip
Add repo_id for attachment (#16958)
When create a new issue or comment and paste/upload an attachment/image, it will not assign an issue id before submit. So if user give up the creating, the attachments will lost key feature and become dirty content. We don't know if we need to delete the attachment even if the repository deleted. This PR add a repo_id in attachment table so that even if a new upload attachment with no issue_id or release_id but should have repo_id. When deleting a repository, they could also be deleted. Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services/wiki/wiki.go')
-rw-r--r--services/wiki/wiki.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go
index e1590f461e..5acb23ac78 100644
--- a/services/wiki/wiki.go
+++ b/services/wiki/wiki.go
@@ -366,3 +366,13 @@ func DeleteWikiPage(doer *models.User, repo *models.Repository, wikiName string)
return nil
}
+
+// DeleteWiki removes the actual and local copy of repository wiki.
+func DeleteWiki(repo *models.Repository) error {
+ if err := models.UpdateRepositoryUnits(repo, nil, []models.UnitType{models.UnitTypeWiki}); err != nil {
+ return err
+ }
+
+ models.RemoveAllWithNotice("Delete repository wiki", repo.WikiPath())
+ return nil
+}