@@ -19,6 +19,8 @@ import (
19
19
"net/http"
20
20
"strings"
21
21
22
+ "github.com/documize/community/core/env"
23
+
22
24
api "github.com/documize/community/core/convapi"
23
25
"github.com/documize/community/core/request"
24
26
"github.com/documize/community/core/response"
@@ -139,7 +141,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
139
141
return
140
142
}
141
143
142
- nd , err := processDocument (ctx , h .Store , filename , job , folderID , fileResult )
144
+ nd , err := processDocument (ctx , h .Runtime , h . Store , filename , job , folderID , fileResult )
143
145
if err != nil {
144
146
response .WriteServerError (w , method , err )
145
147
h .Runtime .Log .Error (method , err )
@@ -152,7 +154,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
152
154
response .WriteJSON (w , nd )
153
155
}
154
156
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 ) {
156
158
// Convert into database objects
157
159
document := convertFileResult (filename , fileResult )
158
160
document .Job = job
@@ -222,6 +224,8 @@ func processDocument(ctx domain.RequestContext, store *domain.Store, filename, j
222
224
}
223
225
}
224
226
227
+ ctx .Transaction .Commit ()
228
+
225
229
newDocument , err = store .Document .Get (ctx , documentID )
226
230
if err != nil {
227
231
ctx .Transaction .Rollback ()
@@ -244,8 +248,6 @@ func processDocument(ctx domain.RequestContext, store *domain.Store, filename, j
244
248
245
249
store .Audit .Record (ctx , audit .EventTypeDocumentUpload )
246
250
247
- ctx .Transaction .Commit ()
248
-
249
251
return
250
252
}
251
253
0 commit comments