mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
Optimize space deletion process
Utilize multiple SQL transactions to close out the space deletion process.
This commit is contained in:
parent
d05052a5b4
commit
d281621d90
5 changed files with 804 additions and 795 deletions
|
@ -17,6 +17,8 @@ echo "Copying Ember assets folder"
|
||||||
robocopy /e /NFL /NDL /NJH gui\dist-prod\assets embed\bindata\public\assets
|
robocopy /e /NFL /NDL /NJH gui\dist-prod\assets embed\bindata\public\assets
|
||||||
echo "Copying Ember codemirror folder"
|
echo "Copying Ember codemirror folder"
|
||||||
robocopy /e /NFL /NDL /NJH gui\dist-prod\codemirror embed\bindata\public\codemirror
|
robocopy /e /NFL /NDL /NJH gui\dist-prod\codemirror embed\bindata\public\codemirror
|
||||||
|
echo "Copying Ember prism folder"
|
||||||
|
robocopy /e /NFL /NDL /NJH gui\dist-prod\prism embed\bindata\public\prism
|
||||||
echo "Copying Ember tinymce folder"
|
echo "Copying Ember tinymce folder"
|
||||||
robocopy /e /NFL /NDL /NJH gui\dist-prod\tinymce embed\bindata\public\tinymce
|
robocopy /e /NFL /NDL /NJH gui\dist-prod\tinymce embed\bindata\public\tinymce
|
||||||
echo "Copying Ember sections folder"
|
echo "Copying Ember sections folder"
|
||||||
|
|
|
@ -248,6 +248,12 @@ func processDocument(ctx domain.RequestContext, r *env.Runtime, store *store.Sto
|
||||||
SourceType: activity.SourceTypeDocument,
|
SourceType: activity.SourceTypeDocument,
|
||||||
ActivityType: activity.TypeCreated})
|
ActivityType: activity.TypeCreated})
|
||||||
|
|
||||||
|
err = store.Space.IncrementContentCount(ctx, newDocument.SpaceID)
|
||||||
|
if err != nil {
|
||||||
|
err = errors.Wrap(err, "cannot increment space content count")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = ctx.Transaction.Commit()
|
err = ctx.Transaction.Commit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "cannot commit new document import")
|
err = errors.Wrap(err, "cannot commit new document import")
|
||||||
|
@ -262,12 +268,6 @@ func processDocument(ctx domain.RequestContext, r *env.Runtime, store *store.Sto
|
||||||
|
|
||||||
go indexer.IndexDocument(ctx, newDocument, da)
|
go indexer.IndexDocument(ctx, newDocument, da)
|
||||||
|
|
||||||
err = store.Space.IncrementContentCount(ctx, newDocument.SpaceID)
|
|
||||||
if err != nil {
|
|
||||||
err = errors.Wrap(err, "cannot increment space content count")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
store.Audit.Record(ctx, audit.EventTypeDocumentUpload)
|
store.Audit.Record(ctx, audit.EventTypeDocumentUpload)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -676,6 +676,7 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete the space first.
|
||||||
ok := true
|
ok := true
|
||||||
ctx.Transaction, ok = h.Runtime.StartTx()
|
ctx.Transaction, ok = h.Runtime.StartTx()
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -683,7 +684,23 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := h.Store.Document.DeleteBySpace(ctx, id)
|
_, err := h.Store.Space.Delete(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
h.Runtime.Rollback(ctx.Transaction)
|
||||||
|
response.WriteServerError(w, method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.Runtime.Commit(ctx.Transaction)
|
||||||
|
|
||||||
|
// Delete data associated with this space.
|
||||||
|
ctx.Transaction, ok = h.Runtime.StartTx()
|
||||||
|
if !ok {
|
||||||
|
response.WriteError(w, method)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = h.Store.Document.DeleteBySpace(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Runtime.Rollback(ctx.Transaction)
|
h.Runtime.Rollback(ctx.Transaction)
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
@ -697,7 +714,6 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove category permissions
|
|
||||||
_, err = h.Store.Permission.DeleteSpaceCategoryPermissions(ctx, id)
|
_, err = h.Store.Permission.DeleteSpaceCategoryPermissions(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Runtime.Rollback(ctx.Transaction)
|
h.Runtime.Rollback(ctx.Transaction)
|
||||||
|
@ -705,6 +721,13 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = h.Store.Category.DeleteBySpace(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
h.Runtime.Rollback(ctx.Transaction)
|
||||||
|
response.WriteServerError(w, method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = h.Store.Pin.DeletePinnedSpace(ctx, id)
|
_, err = h.Store.Pin.DeletePinnedSpace(ctx, id)
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
h.Runtime.Rollback(ctx.Transaction)
|
h.Runtime.Rollback(ctx.Transaction)
|
||||||
|
@ -712,22 +735,6 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove category and members for space
|
|
||||||
_, err = h.Store.Category.DeleteBySpace(ctx, id)
|
|
||||||
if err != nil {
|
|
||||||
h.Runtime.Rollback(ctx.Transaction)
|
|
||||||
response.WriteServerError(w, method, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = h.Store.Space.Delete(ctx, id)
|
|
||||||
if err != nil {
|
|
||||||
h.Runtime.Rollback(ctx.Transaction)
|
|
||||||
response.WriteServerError(w, method, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close out the delete process
|
|
||||||
h.Runtime.Commit(ctx.Transaction)
|
h.Runtime.Commit(ctx.Transaction)
|
||||||
|
|
||||||
// Record this action.
|
// Record this action.
|
||||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
||||||
rt.Product.Major = "2"
|
rt.Product.Major = "2"
|
||||||
rt.Product.Minor = "0"
|
rt.Product.Minor = "0"
|
||||||
rt.Product.Patch = "0"
|
rt.Product.Patch = "0"
|
||||||
rt.Product.Revision = 190108173435
|
rt.Product.Revision = 190114220236
|
||||||
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||||
rt.Product.Edition = domain.CommunityEdition
|
rt.Product.Edition = domain.CommunityEdition
|
||||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||||
|
|
1540
embed/bindata.go
1540
embed/bindata.go
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue