Skip to content

Commit 17db964

Browse files
committed
new document commit tweak
1 parent adbe93a commit 17db964

File tree

2 files changed

+631
-629
lines changed

2 files changed

+631
-629
lines changed

domain/conversion/conversion.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"net/http"
2020
"strings"
2121

22+
"github.com/documize/community/core/env"
23+
2224
api "github.com/documize/community/core/convapi"
2325
"github.com/documize/community/core/request"
2426
"github.com/documize/community/core/response"
@@ -139,7 +141,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
139141
return
140142
}
141143

142-
nd, err := processDocument(ctx, h.Store, filename, job, folderID, fileResult)
144+
nd, err := processDocument(ctx, h.Runtime, h.Store, filename, job, folderID, fileResult)
143145
if err != nil {
144146
response.WriteServerError(w, method, err)
145147
h.Runtime.Log.Error(method, err)
@@ -152,7 +154,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
152154
response.WriteJSON(w, nd)
153155
}
154156

155-
func processDocument(ctx domain.RequestContext, store *domain.Store, filename, job, folderID string, fileResult *api.DocumentConversionResponse) (newDocument doc.Document, err error) {
157+
func processDocument(ctx domain.RequestContext, r *env.Runtime, store *domain.Store, filename, job, folderID string, fileResult *api.DocumentConversionResponse) (newDocument doc.Document, err error) {
156158
// Convert into database objects
157159
document := convertFileResult(filename, fileResult)
158160
document.Job = job
@@ -222,6 +224,8 @@ func processDocument(ctx domain.RequestContext, store *domain.Store, filename, j
222224
}
223225
}
224226

227+
ctx.Transaction.Commit()
228+
225229
newDocument, err = store.Document.Get(ctx, documentID)
226230
if err != nil {
227231
ctx.Transaction.Rollback()
@@ -244,8 +248,6 @@ func processDocument(ctx domain.RequestContext, store *domain.Store, filename, j
244248

245249
store.Audit.Record(ctx, audit.EventTypeDocumentUpload)
246250

247-
ctx.Transaction.Commit()
248-
249251
return
250252
}
251253

0 commit comments

Comments
 (0)