Unified stack refactor clean up
Clean up obsolete code and some warnings
parent: tbd commit: 356f714
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , | UserAuthenticationToken
6 | , |
7 | |
8 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
9 | , |
10 | , | ObjectBackend
11 | |
12 | Commit, DefaultBranch, Description, LatestCommit, Repository, |
13 | RepositoryCommitBeforeRequest, RepositoryDiff, RepositoryDiffPatchRequest, |
14 | RepositoryDiffRequest, RepositoryFile, RepositoryFileFromIdRequest, |
15 | RepositoryFileFromPathRequest, RepositoryFileInspectRequest, RepositoryInfoRequest, |
16 | RepositorySummary, RepositoryView, Visibility, |
17 | , |
18 | , |
19 | , |
20 | , |
21 | ; |
22 | use |
23 | , AuthenticatedUser, AuthorizedInstance, AuthorizedUser, | GiteratedRuntime
24 | StackOperationState, |
25 | ; |
26 | |
27 | use DatabaseBackend; |
28 | |
29 | |
30 | object: &User, |
31 | _operation: UserRepositoriesRequest, |
32 | state: DatabaseBackend, |
33 | _operation_state: StackOperationState, |
34 | requester: , |
35 | |
36 | let object = object.clone; |
37 | |
38 | async move |
39 | let mut user_backend = state.user_backend.lock .await; |
40 | let repositories_response = user_backend |
41 | .repositories_for_user |
42 | .await |
43 | .map_err?; |
44 | drop; |
45 | let mut repositories_backend = state.repository_backend.lock .await; |
46 | |
47 | let mut repositories = vec!; |
48 | |
49 | for repository in repositories_response |
50 | if repositories_backend |
51 | .exists |
52 | .await |
53 | .map_err? |
54 | |
55 | repositories.push; |
56 | |
57 | |
58 | |
59 | Ok |
60 | |
61 | .boxed |
62 | |
63 | |
64 | |
65 | object: &User, |
66 | operation: , |
67 | state: DatabaseBackend, |
68 | |
69 | let object = object.clone; |
70 | |
71 | async move |
72 | let mut user_backend = state.user_backend.lock .await; |
73 | let value = user_backend |
74 | .get_value |
75 | .await |
76 | .map_err?; |
77 | |
78 | Ok |
79 | |
80 | .boxed |
81 | |
82 | |
83 | |
84 | object: &User, |
85 | operation: GetSetting, |
86 | state: DatabaseBackend, |
87 | |
88 | let object = object.clone; |
89 | |
90 | async move |
91 | let mut user_backend = state.user_backend.lock .await; |
92 | let value = user_backend |
93 | .get_setting |
94 | .await |
95 | .map_err?; |
96 | |
97 | Ok |
98 | |
99 | .boxed |
100 | |
101 | |
102 | |
103 | object: &Repository, |
104 | operation: RepositoryInfoRequest, |
105 | state: DatabaseBackend, |
106 | operation_state: StackOperationState, |
107 | backend: , |
108 | requester: , |
109 | |
110 | let object = object.clone; |
111 | |
112 | async move |
113 | let mut object = backend |
114 | . |
115 | .await |
116 | .unwrap; |
117 | |
118 | let mut repository_backend = state.repository_backend.lock .await; |
119 | let tree = repository_backend |
120 | .repository_file_inspect |
121 | &requester, |
122 | object.object, |
123 | &RepositoryFileInspectRequest |
124 | extra_metadata: operation.extra_metadata, |
125 | path: operation.path, |
126 | rev: operation.rev.clone, |
127 | , |
128 | |
129 | .await |
130 | .map_err?; |
131 | drop; |
132 | |
133 | let info = RepositoryView |
134 | name: object.object .name.clone, |
135 | owner: object.object .owner.clone, |
136 | description: object. .await.ok, |
137 | visibility: object |
138 | . |
139 | .await |
140 | .map_err?, |
141 | default_branch: object |
142 | . |
143 | .await |
144 | .map_err?, |
145 | // TODO: Can't be a simple get function, this needs to be returned alongside the tree as this differs depending on the rev and path. |
146 | latest_commit: object. .await.ok, |
147 | tree_rev: operation.rev, |
148 | tree, |
149 | ; |
150 | |
151 | Ok |
152 | |
153 | .boxed |
154 | |
155 | |
156 | |
157 | object: &Repository, |
158 | operation: RepositoryFileFromIdRequest, |
159 | state: DatabaseBackend, |
160 | operation_state: StackOperationState, |
161 | backend: , |
162 | |
163 | requester: , |
164 | |
165 | let object = object.clone; |
166 | |
167 | async move |
168 | let object = backend |
169 | . |
170 | .await |
171 | .unwrap; |
172 | |
173 | let mut repository_backend = state.repository_backend.lock .await; |
174 | let file = repository_backend |
175 | .repository_file_from_id |
176 | &requester, |
177 | object.object, |
178 | &RepositoryFileFromIdRequest, |
179 | |
180 | .await |
181 | .map_err?; |
182 | drop; |
183 | |
184 | Ok |
185 | |
186 | .boxed |
187 | |
188 | |
189 | |
190 | object: &Repository, |
191 | operation: RepositoryFileFromPathRequest, |
192 | state: DatabaseBackend, |
193 | operation_state: StackOperationState, |
194 | backend: , |
195 | requester: , |
196 | |
197 | let object = object.clone; |
198 | |
199 | async move |
200 | let object = backend |
201 | . |
202 | .await |
203 | .unwrap; |
204 | |
205 | let mut repository_backend = state.repository_backend.lock .await; |
206 | let file = repository_backend |
207 | .repository_file_from_path |
208 | &requester, |
209 | object.object, |
210 | &RepositoryFileFromPathRequest |
211 | rev: operation.rev, |
212 | path: operation.path, |
213 | , |
214 | |
215 | .await |
216 | .map_err?; |
217 | drop; |
218 | |
219 | Ok |
220 | |
221 | .boxed |
222 | |
223 | |
224 | |
225 | object: &Repository, |
226 | operation: RepositoryDiffRequest, |
227 | state: DatabaseBackend, |
228 | operation_state: StackOperationState, |
229 | backend: , |
230 | requester: , |
231 | |
232 | let object = object.clone; |
233 | |
234 | async move |
235 | let object = backend |
236 | . |
237 | .await |
238 | .unwrap; |
239 | |
240 | let mut repository_backend = state.repository_backend.lock .await; |
241 | let diff = repository_backend |
242 | .repository_diff |
243 | .await |
244 | .map_err?; |
245 | drop; |
246 | |
247 | Ok |
248 | |
249 | .boxed |
250 | |
251 | |
252 | |
253 | object: &Repository, |
254 | operation: RepositoryDiffPatchRequest, |
255 | state: DatabaseBackend, |
256 | operation_state: StackOperationState, |
257 | backend: , |
258 | requester: , |
259 | |
260 | let object = object.clone; |
261 | |
262 | async move |
263 | let object = backend |
264 | . |
265 | .await |
266 | .unwrap; |
267 | |
268 | let mut repository_backend = state.repository_backend.lock .await; |
269 | let patch = repository_backend |
270 | .repository_diff_patch |
271 | .await |
272 | .map_err?; |
273 | drop; |
274 | |
275 | Ok |
276 | |
277 | .boxed |
278 | |
279 | |
280 | |
281 | object: &Repository, |
282 | operation: RepositoryCommitBeforeRequest, |
283 | state: DatabaseBackend, |
284 | operation_state: StackOperationState, |
285 | backend: , |
286 | requester: , |
287 | |
288 | let object = object.clone; |
289 | |
290 | async move |
291 | let object = backend |
292 | . |
293 | .await |
294 | .unwrap; |
295 | |
296 | let mut repository_backend = state.repository_backend.lock .await; |
297 | let file = repository_backend |
298 | .repository_commit_before |
299 | .await |
300 | .map_err?; |
301 | drop; |
302 | |
303 | Ok |
304 | |
305 | .boxed |
306 | |
307 | |
308 | |
309 | object: &Repository, |
310 | operation: , |
311 | state: DatabaseBackend, |
312 | |
313 | let object = object.clone; |
314 | |
315 | async move |
316 | let mut repository_backend = state.repository_backend.lock .await; |
317 | let value = repository_backend |
318 | .get_value |
319 | .await |
320 | .map_err |
321 | Internal |
322 | ?; |
323 | |
324 | Ok |
325 | |
326 | .boxed |
327 | |
328 | |
329 | |
330 | object: &Repository, |
331 | operation: GetSetting, |
332 | state: DatabaseBackend, |
333 | |
334 | let object = object.clone; |
335 | |
336 | async move |
337 | let mut repository_backend = state.repository_backend.lock .await; |
338 | let value = repository_backend |
339 | .get_setting |
340 | .await |
341 | .map_err?; |
342 | |
343 | Ok |
344 | |
345 | .boxed |
346 | |
347 | |
348 | |
349 | object: &Instance, |
350 | operation: AuthenticationTokenRequest, |
351 | state: DatabaseBackend, |
352 | // Authorizes the request for SAME-INSTANCE |
353 | _authorized_instance: AuthorizedInstance, |
354 | |
355 | let object = object.clone; |
356 | async move |
357 | let mut backend = state.user_backend.lock .await; |
358 | |
359 | backend |
360 | .login |
361 | .await |
362 | .map_err |
363 | |
364 | .boxed |
365 | |
366 | |
367 | |
368 | _object: &Instance, |
369 | operation: RegisterAccountRequest, |
370 | state: DatabaseBackend, |
371 | // Authorizes the request for SAME-INSTANCE |
372 | _authorized_instance: AuthorizedInstance, |
373 | |
374 | async move |
375 | let mut backend = state.user_backend.lock .await; |
376 | |
377 | backend |
378 | .register |
379 | .await |
380 | .map_err |
381 | |
382 | .boxed |
383 | |
384 | |
385 | |
386 | _object: &Instance, |
387 | operation: RepositoryCreateRequest, |
388 | state: DatabaseBackend, |
389 | requester: AuthenticatedUser, |
390 | // Authorizes the request for SAME-INSTANCE |
391 | _authorized_instance: AuthorizedInstance, |
392 | |
393 | async move |
394 | let mut backend = state.repository_backend.lock .await; |
395 | |
396 | backend |
397 | .create_repository |
398 | .await |
399 | .map_err |
400 | |
401 | .boxed |
402 | |
403 | |
404 | |
405 | object: &User, |
406 | operation: , |
407 | state: DatabaseBackend, |
408 | _requester: AuthorizedUser, |
409 | |
410 | let object = object.clone; |
411 | |
412 | async move |
413 | let mut backend = state.user_backend.lock .await; |
414 | |
415 | let raw_value = backend |
416 | .get_value |
417 | .await |
418 | .map_err?; |
419 | |
420 | Ok |
421 | .map_err? |
422 | |
423 | .boxed |
424 | |
425 | |
426 | |
427 | object: &User, |
428 | operation: , |
429 | state: DatabaseBackend, |
430 | |
431 | let object = object.clone; |
432 | |
433 | async move |
434 | let mut backend = state.user_backend.lock .await; |
435 | |
436 | let raw_value = backend |
437 | .get_value |
438 | .await |
439 | .map_err?; |
440 | |
441 | Ok |
442 | .map_err? |
443 | |
444 | .boxed |
445 | |
446 | |
447 | |
448 | object: &Repository, |
449 | operation: , |
450 | state: DatabaseBackend, |
451 | |
452 | let object = object.clone; |
453 | |
454 | async move |
455 | let mut backend = state.repository_backend.lock .await; |
456 | |
457 | let raw_value = backend |
458 | .get_value |
459 | .await |
460 | .map_err?; |
461 | |
462 | Ok |
463 | .map_err? |
464 | |
465 | .boxed |
466 | |
467 | |
468 | |
469 | object: &Repository, |
470 | operation: , |
471 | state: DatabaseBackend, |
472 | |
473 | let object = object.clone; |
474 | |
475 | async move |
476 | let mut backend = state.repository_backend.lock .await; |
477 | |
478 | let raw_value = backend |
479 | .get_value |
480 | .await |
481 | .map_err?; |
482 | |
483 | Ok |
484 | .map_err? |
485 | |
486 | .boxed |
487 | |
488 |